import requests
from lxml import etree
bd = requests.get('
bd.encodong='ISO-8859-1'
html =etree.HTML(bd.text)
h1 = html.xpath('//*[@id="blk_detail_info"]/div[1]/div/img/@src')[0]
h2 ='http:'+ h1
t=requests.get(h2)
with open('ez.jpg','wb') as f:
f.write(t.content)
错误提示如下:
Traceback (most recent call last):
File "F:/python/爬虫学习/EZ.py", line 8, in <module>
h1 = html.xpath('//*[@id="blk_detail_info"]/div[1]/div/img/@src')[0]
IndexError: list index out of range
添加回答
举报
0/150
提交
取消