发布时间:2019-08-02 16:20:26
本人菜鸟一枚,奈何领导让我学习爬虫,我就简单学着写了点爬虫,但是爬下来的图片打不开或已损坏,球大神指点迷津,感谢
import requests
from bs4 import BeautifulSoup
url='http://newcar.xcar..cn/photo/m38486/'
res=requests.get(url)
soup=BeautifulSoup(res.text,'html.parser')
ID=1
for A in soup.select('dl'):
for B in A.select('dt'):
for C in B.select ('img'):
print C['src']
D=C['src']
jepg=open('E:\Python\PythonJDPG\\'+str(ID)+'.jpg','wb')
jepg.write(D)
jepg.close
ID+=1