169美女图片

import requests
# from lxml import etree
from pyquery import PyQuery
# from bs4 import BeautifulSoup

count = 1
url = "https://www.169tp.com/rentiyishu/"
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'}
reponse = requests.get(url,headers=headers).text
# print(reponse)
doc = PyQuery(reponse)
url_data = doc('.product01 li a').items()
for i in url_data:
xulie = i.attr('href')
# print(xulie)

reponse1 = requests.get(xulie,headers=headers).text

# print(reponse1)
doc2 = PyQuery(reponse1)
tupian = doc2('.big_img p img').items()
for k in tupian:
img = k.attr('src')
# title = k.attr('alt')
# print(img)

 

contont = requests.get(img,headers=headers)
with open('.\模特\美女{}.jpg'.format(count),'wb') as f:
f.write(contont.content)
print('已经下载了{}张'.format(count))
count+=1

上一篇:LeetCode-169 求众数


下一篇:RDD之action算子