Python/biyingSpider.py

16 lines
334 B
Python
Raw Normal View History

2016-12-09 14:22:52 +08:00
import requests
import re
import time
local = time.strftime("%Y.%m.%d")
url = 'http://cn.bing.com/'
con = requests.get(url)
content = con.text
2018-02-13 09:02:17 +08:00
reg = r"(az/hprichbg/rb/.*?.jpg)"
2016-12-09 14:22:52 +08:00
a = re.findall(reg, content, re.S)[0]
print(a)
2018-02-13 09:02:17 +08:00
picUrl = url + a
read = requests.get(picUrl)
2016-12-09 14:22:52 +08:00
f = open('%s.jpg' % local, 'wb')
f.write(read.content)
f.close()