91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-14
  • 語言: Python
  • 標簽: 爬蟲??圖片??

資源簡介

指定配置與車型,自動爬取車型配置信息,程序為爬取屏幕尺寸大小,可以根據自己的需求自行更改

資源截圖

代碼片段和文件信息


#?-*-?coding:?utf-8?-*-
import?requests
import?re
import?time
import?sys
import?os


homedir?=?os.getcwd()
#新能源汽車網址
car_url=“https://www.autohome.com.cn/car/0_0-0.0_0.0-0-0-0-0-4-0-0-0/“
#zg=[]
#2018年1月28?該下載N
#燃油版
#temp=[‘A‘‘B‘‘C‘‘D‘‘E‘‘F‘‘G‘‘H‘‘I‘‘J‘‘K‘‘L‘‘M‘‘N‘‘O‘‘P‘‘Q‘‘R‘‘S‘‘T‘‘V‘‘W‘‘X‘‘Y‘‘Z‘]
#純電版
#temp=[‘B‘‘C‘‘D‘‘F‘‘G‘‘H‘‘J‘‘K‘‘L‘‘N‘‘O‘‘Q‘‘R‘‘S‘‘T‘‘W‘‘X‘‘Y‘‘Z‘]
#for?i?in?temp:
????#print(“正在訪問:“i)
????#car_url=“https://www.autohome.com.cn/grade/carhtml/“+i+“.html“
????#zg.append(car_url)
????#print(car_url)
#print(zg)

#下載器
def?download(url):
????try:
????????response=requests.get(url)
????????#response.encoding=‘gb2312‘
????????if?response:
????????????global?html
????????????type?=?sys.getfilesystemencoding()
????????????html=response.text
????????????html?=?html.encode(‘utf-8‘).decode(‘utf-8‘)
????????????return?html
????????#print(html)
????except?Exception?as?e:
????????print(e)
def?save_carname():
????path_result=homedir+‘\\‘+‘車型.txt‘
????f1?=?open(path_result‘a‘)
????f1.write(name[0]+‘\n‘)
????f1.close()
def?save_num():
????path_result=homedir+‘\\‘+‘屏幕尺寸.txt‘
????f1?=?open(path_result‘a‘)
????f1.write(m.group(0)+‘\n‘)
????f1.close()????
download(car_url)
html_1=html
img_url_1=re.findall(r‘href=“//car.autohome.com.cn/price/(.*?).html#pvareaid=103446“‘?html_1?)
#print(img_url_1)
#獲取所有當前字母開頭車型報價URL
img_url_item=list(map(lambda?x:?‘https://car.autohome.com.cn/price/‘+x+‘.html#pvareaid=103446‘img_url_1))
#print(len(img_url_item))
for?p?in?img_url_item:
????try:

評論

共有 條評論