首页 > 其他分享 >再来爬取4K美女图片

再来爬取4K美女图片

时间:2022-12-23 13:00:14浏览次数:44  
标签:再来 name img url text pic 4K 美女 page

import requests
import os
from lxml import etree

dirName = "./4kmeimv"
if not os.path.exists(dirName):
os.mkdir(dirName)
url = "http://pic.netbian.com/4kmeinv/index_%d.html"
for page in range(1, 11):
if page == 1:
new_url = "http://pic.netbian.com/4kmeinv/"
else:
new_url = format(url % page)
page_text = requests.get(new_url).text
tree = etree.HTML(page_text)
a_list = tree.xpath('//div[@class="slist"]/ul/li/a')
for a in a_list:
img_src = "http://pic.netbian.com" + a.xpath("./img/@src")[0]
img_name = a.xpath("./b/text()")[0]
img_name = img_name.encode('iso-8859-1').decode('gbk')
img_data = requests.get(img_src).content
imgPath = dirName + '/' + img_name + '.jpg'
with open(imgPath, "wb") as fp:
fp.write(img_data)
print(img_name, "下载成功")

再来爬取4K美女图片_.net

 

 

 



标签:再来,name,img,url,text,pic,4K,美女,page
From: https://blog.51cto.com/u_15920572/5965391

相关文章