您的位置:首页 > 理论基础 > 计算机网络

python 3 网络爬取图片之二

2017-01-12 16:56 162 查看
import webbrowser, requests, bs4, re, os

url = "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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 爬虫