import requests
from bs4 import BeautifulSoup
start = input("请输入开始页数(只能从2开始):")
end = input("请输入结束页数:")
start = int(start)
end = int(end)
for sum in range(start,end):
url = f'https://pic.netbian.com/4kmeinv/index_{sum}.html'
domain = "https://pic.netbian.com/"
srcmain = "https://pic.netbian.com/"
headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27"
}
resp = requests.get(url)
resp.encoding = "gbk"
# print(resp.text)
main_page = BeautifulSoup(resp.text,"html.parser")
alist = main_page.find("div",attrs={"class":"slist"}).find_all("a")
# print(alist)
for a in alist:
child_href = domain + a.get('href').strip("/"
利用python爬虫进行彼岸网图库图片的抓取(bs4)
于 2022-11-08 16:29:53 首次发布