python 3 网络爬取图片之二

来源:互联网 发布:xp保存网络密码 编辑:程序博客网 时间:2024/06/15 02:55
import webbrowser, requests, bs4, re, osurl = "https://www.sogou.com"res = requests.get(url)soup = bs4.BeautifulSoup(res.text, "html.parser")img = soup.select('img')comicUrl = img[0].get('src')imageFile = open(os.path.join('c:\\u', os.path.basename(comicUrl)), 'wb')res1 = requests.get(url+comicUrl)for chunk in res.iter_content(100000):    imageFile.write(chunk)imageFile.close()

1 0