python3 爬虫

xiaoxiao2021-02-28  73

转载点击打开链接

我的第一个爬虫代码,好开心^-^~

import requests import re def f(html): r = re.compile(r'http://imgsrc.baidu.com/forum/w=580/[a-z0-9\=/]+.jpg') r1 = requests.get(html) imgs = re.findall(r, r1.text) x = 1 for img in imgs: r = requests.get(img) with open('img%d.jpg' % x, 'wb') as f: f.write(r.content) x += 1 f('http://tieba.baidu.com/p/5103378450')

转载请注明原文地址: https://www.6miu.com/read-75445.html

最新回复(0)