Skip to content

Commit

Permalink
Update spider.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antares927 authored Feb 7, 2020
1 parent 1ced758 commit c3068f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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)
Expand Down

0 comments on commit c3068f5

Please sign in to comment.