import requests
from pyquery import PyQuery
count = 1
start_url = "https://www.169tp.com/xingganmeinv/list_1_{}.html"
# 'https://www.169tp.com/xingganmeinv/list_1_1.html'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
}
for more in range(662):
url=start_url.format(more+1)
# print(url)
reponse = requests.get(url,headers=headers).text
doc = PyQuery(reponse)
data_url = doc('.product01 li a').items()
for i in data_url:
images_url= i.attr('href')
url_image = requests.get(images_url, headers=headers).text
doc2= PyQuery(url_image)
tp_url = doc2('.big_img p img ').items()
print(tp_url)
for k in tp_url:
src = k.attr('src')
# print(src)
meinvtu = requests.get(src, headers=headers)
with open('./images/美女{}.jpg'.format(count),'wb') as f:
f.write(meinvtu.content)
print('已经下载{}张美女图片'.format(count))
f.close()
count +=1