用于网站爬图 代码太多,贴关键部分,应该问题就出自以下爬虫部分:
for i in soup1.find_all("input", type="image"):
imgnow = time.strftime("%Y%m%d%H%M%S")
imgurl = i['data-src']
rname = imgurl .split('/')[-1]
opener = urllib.request.build_opener()
opener.addheaders = self.UA
urllib.request.install_opener(opener)
try:
#就是卡这里不动了,没有任何动静,程序静止了
urllib.request.urlretrieve(
imgurl, "./Pic/%s" % imgnow + "_" + str(rname))
except Exception as e:
print("出错了:%s,继续..." % e)
continue