-
-
Save vshivam/3252815 to your computer and use it in GitHub Desktop.
Retrieve Latest xkcd
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
| import urllib | |
| def xkcd_latest(): | |
| source = urllib.urlopen('http://xkcd.com/').read() | |
| url_start = source.find('img src="http://imgs.xkcd.com/comics/') | |
| start_quote = source.find('"',url_start) | |
| end_quote = source.find('"',start_quote+1) | |
| url=source[start_quote+1:end_quote] | |
| file_name = url[28:end_quote] | |
| print file_name | |
| print url | |
| image_file = urllib.urlretrieve(url, "C:\\Python\\xkcd\\"+file_name) | |
| xkcd_latest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment