Created
September 16, 2012 05:22
-
-
Save Answeror/3731112 to your computer and use it in GitHub Desktop.
程序员的爱情表白
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # fetch jpgs from tuita | |
| import urllib3 | |
| from pyquery import PyQuery as pq | |
| http = urllib3.PoolManager() | |
| url = 'http://yokicharlotte.tuita.com/blogpost/23832258' | |
| r = http.request('GET', url) | |
| d = pq(r.data.decode('utf-8')) | |
| imgs = d('.photo_group')('p.pic')('img') | |
| imgs.map(lambda e: pq(this).attr('src')) | |
| srcs = imgs.map(lambda e: pq(this).attr('src')) | |
| for i, src in enumerate(srcs): | |
| print('do %02d' % i) | |
| while True: | |
| r = http.request('GET', src) | |
| if r.status == 200: | |
| break | |
| print('retry') | |
| with open('%02d.jpg' % i, 'wb') as f: | |
| f.write(r.data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment