时间:2023-07-05 16:42:01 | 来源:网站运营
时间:2023-07-05 16:42:01 来源:网站运营
编写网页信息爬取脚本:配置import requestsimport reurl = "http://192.168.113.129/pythonSpider/"def get_html(url): res = requests.get(url = url) html = res.content.decode() return htmldef get_img_path(html): _img_path_list = re.findall("style/u/w*/.jpg", html) img_path_list = [] for i in _img_path_list: img_path_list.append(url + i) return img_path_listdef get_img(url, img_name): res = requests.get(url = url) with open(f"./img/{img_name}", "wb") as f: f.write(res.content)html = get_html(url)img_path_list = get_img_path(html)i = 1for img_path in img_path_list: img_name = f"{i}.jpg" get_img(img_path, img_name) i +=1
关键词:脚本,信息,编写