转载点击打开链接
我的第一个爬虫代码,好开心^-^~
import requests
import re
def f(html):
r = re.compile(r'http://imgsrc.baidu.com/forum/w%3D580/[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')