Skip to content

Instantly share code, notes, and snippets.

@groob
Created July 23, 2014 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groob/c74450740a382eaeebda to your computer and use it in GitHub Desktop.
Save groob/c74450740a382eaeebda to your computer and use it in GitHub Desktop.
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