Created
July 23, 2014 21:33
-
-
Save groob/c74450740a382eaeebda to your computer and use it in GitHub Desktop.
This file contains 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 re | |
import urllib2 | |
import urllib | |
import urlparse | |
index_url = 'https://www.makerbot.com/desktop' | |
f = urllib2.urlopen(index_url) | |
html = f.read() | |
f.close() | |
rex_dmg = re.compile(r'a[^>]* href="(?P<filename>[^"]+\.dmg)"') | |
re_dmg = re.compile(r'urlMac": "(?P<filename>[^"]+\.dmg)') | |
m = re_dmg.search(html) | |
url_bits = urlparse.urlsplit(m.group("filename")) | |
encoded_path = urllib.quote(url_bits.path) | |
url = url_bits.scheme + "://" + url_bits.netloc + encoded_path | |
print m.group("filename") | |
print encoded_path | |
print url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment