使用requests批量爬取妹子写真集
首先感谢tzhang56 老铁!感谢提供的url 哈哈哈!顺带参考下你的代码{:5_109:}只有不到20行代码实现。如果没有pics文件夹请创建import requests
def get_image():
amount = int(input('希望获取第多少部写真\n:'))
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/80.0.3987.163 Safari/537.36'}
root = int(amount)
while root >= 10:
for num in range(100):
url = 'https://mtl.gzhuibei.com/images/img/' + str(root) + '/' + str(num) + '.jpg'
print(url)
r = requests.get(url, headers=header)
if r.status_code == 200:
with open("D://pics/" + str(root) + str(num) + ".jpg", 'wb') as file:
file.write(r.content)
root -= 1
get_image()
最后展示下{:5_97:} 是爬取多张吗 MIke_python小小 发表于 2020-4-24 09:55
是爬取多张吗
看我的照片文件数量
页:
[1]