1. 程式人生 > >爬取好看的妹子圖片喲~ -《狗嗨默示錄》-

爬取好看的妹子圖片喲~ -《狗嗨默示錄》-

http urlopen decode urn com all pil soft ont

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import urllib.request
import re

#獲取源碼
def gethtml():
papg = urllib.request.urlopen(‘https://www.4493.com/‘)
html = papg.read().decode(‘gbk‘)
#print(html)
return html

#下載圖片
def getimg(html):
imgre = re.compile(r‘ lazysrc="(.*?)" ‘)
imglist = re.findall(imgre,html)#匹配

print(imglist)
x = 0
for imgurl in imglist:
urllib.request.urlretrieve(imgurl, ‘D:\學習資料\pic\%s.jpg‘ % x)
x += 1

html = gethtml()
getimg(html)

爬取好看的妹子圖片喲~ -《狗嗨默示錄》-