import requests
from bs4 import BeautifulSoup
url = "https://umei.net/bizhitupian/meinvbizhi/yangyanmeinv.htm"
resp = requests.get(url)
resp.encoding = "utf-8"
page = BeautifulSoup(resp.text)
alist = page.find('div',class_="TypeList").find_all('a')
for a in alist:
b = a.get("href")
href = "https://umei.net/" + b
child_page_resp = requests.get(href)
child_page_resp.encoding = "utf-8"
child_page = BeautifulSoup(child_page_resp.text)
try:
img = child_page.find('p',align="center").find('img')
except:
break
src = img.get('src')
img_resp = requests.get(src)
img_name = src.split('/')[-1]#获取连接中最后一块作为保存名
with open(img_name,mode = 'wb') as f:
f.write(img_resp.content)
print(img_name,'over')
time.sleep(1)
print("allover")
08-04
4992
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交