💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
爬取 https://www.buxiuse.com/?page=2 的图片。 <br/> ```python """ @Date 2021/3/19 """ import requests from bs4 import BeautifulSoup def scr_img(): headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \ (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" } url = "https://www.buxiuse.com/?page=2" r = requests.get(url, headers=headers) if r.status_code != 200: return None soup = BeautifulSoup(r.text, 'lxml') srcs = soup.find_all('img') for index, img in enumerate(srcs): src = img.get('src') with open("E:/python/{}.jpg".format(index), "wb") as f: r2 = requests.get(src, headers=headers) if r2.status_code != 200: continue f.write(r2.content) if __name__ == '__main__': scr_img() ```