From 8e472ffd8ceb61128f71d51b63b65a92cc2a28d8 Mon Sep 17 00:00:00 2001 From: antares927 <49019087+antares927@users.noreply.github.com> Date: Fri, 7 Feb 2020 13:02:34 +0000 Subject: [PATCH] Update spider_ForConvertToEXE.py --- spider_ForConvertToEXE.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spider_ForConvertToEXE.py b/spider_ForConvertToEXE.py index 4fb7be9..65ad9be 100644 --- a/spider_ForConvertToEXE.py +++ b/spider_ForConvertToEXE.py @@ -118,6 +118,10 @@ def read_pic_url(bs): # 读取当前页所有图片URL def download_pic(urlgroup, path): # 下载图片 print("Download start") pattern = re.compile(r"-(.*)") + opener = urllib.request.build_opener() + opener.addheaders = [('User-Agent', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36')] + urllib.request.install_opener(opener) for url in urlgroup: picname = re.findall(pattern, url) print("Picture name:", picname)