import requestsimport sysimport iofrom bs4 import BeautifulSoupimport timesys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')url = 'https://www.umei.cc/bizhitupian/weimeibizhi/'resp = requests.get(url)resp.encoding = 'utf-8'page = BeautifulSoup(resp.text, 'html.parser')main_div = page.find('div', attrs={'class', 'TypeList'}).find_all("a")for i in main_div:href = i.get("href")c_resp = requests.get(href)c_resp.encoding = 'utf-8'c_page_txt = c_resp.textc_page = BeautifulSoup(c_page_txt, 'html.parser')p = c_page.find('p', align='center')img = p.find("img")src = img.get("src")img_resp = requests.get(src)img_name = src.split("/")[-1]with open("img/"+img_name, mode="wb") as f:f.write(img_resp.content)time.sleep(1)摘要:import requestsimport sysimport iofrom bs4 import BeautifulSoupimport timesys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding
来源:科技凡人说
免责声明:本站系转载,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本站联系,我们将在第一时间删除内容!