受程序員群的影響(自己污的本性)毫炉,他們總是帶我開車骨望,想想我也該收集一些資料了(美女圖片)
代碼
import requests
from lxml import etree
urls = ['http://jandan.net/ooxx/page-{}'.format(str(i)) for i in range(0,20)]
path = 'C://Users/Administrator/Desktop/煎蛋網(wǎng)/'
header = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'
}
def get_photo(url):
html = requests.get(url)
selector = etree.HTML(html.text)
photo_urls = selector.xpath('//p/a[@class="view_img_link"]/@href')
for photo_url in photo_urls:
data = requests.get('http:'+photo_url,headers=header)
fp = open(path + photo_url[-10:],'wb')
fp.write(data.content)
fp.close()
for url in urls:
get_photo(url)
我以前做個(gè)視頻,這次用不了们陆,出錯(cuò)屁药,爬蟲只有進(jìn)行時(shí)爸嘌!D鸺8纯鳌!