这是我运行的代码,去爬图片,但试了好几次都不行,而且我电脑上有lxml这个程序包啊,请教各位大佬该怎么解决。
import requests from lxml import etree from urllib import request address = 'https://www.huya.com/g/lol' house = requests.get(address) box = house.text openbox = etree.HTML(box) allpicture = openbox.xpath('//img[@class="pic"]')[0] for a in allpicture: picture = a.xpath('./@data-original') name = a.xpath('./@alt') request.urlretrieve(picture,r'D:/pthon爬虫'+'name'+'.jpg')