好友
阅读权限10
听众
最后登录1970-1-1
|
import requests
import re
import time
import os
# url = 'https://www.vmgirls.com/13344.html'
def get_pic(url):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
}
response = requests.get(url, headers=headers)
html = response.text
# print(response.text)
dir_name = re.findall('<h1 class="post-title h1">(.*?)</h1>',html)[-1]
if not os.path.exists(dir_name):
os.mkdir(dir_name)
urls = re.findall('<a href="(.*?)" alt=".*?" title=".*?">', html)
for url_data in urls:
# time.sleep(1)
urls_data = "https:" + url_data
print(urls_data)
# 图片的名称
file_name = urls_data.split('/')[-1]
# print(file_name)
response_data = requests.get(urls_data, headers = headers)
# print(response_data.content)
with open(dir_name + '/' + file_name, 'wb') as f:
f.write(response_data.content)
url_list =[
'https://www.vmgirls.com/13344.html',
'https://www.vmgirls.com/15881.html',
'https://www.vmgirls.com/15400.html',
'https://www.vmgirls.com/15323.html',
'https://www.vmgirls.com/15370.html'
]
for url1 in url_list:
get_pic(url1) |
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|