-
-
Save tacaswell/0edc759286dfd02e48f1b82a6dbad03f to your computer and use it in GitHub Desktop.
Loops over examples on the matplotlib1.5.1 page and opens the 1.5.1 and 2.0 version in a browser
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
#!/usr/bin/env python | |
import requests | |
import subprocess | |
from lxml import html | |
old_url = 'http://matplotlib.org/1.5.1/examples/' | |
new_url = 'http://matplotlib.org/2.0.0b2/examples/' | |
# Skip any urls containing these strings | |
skip_these = ['animation/', 'api/'] | |
if __name__ == '__main__': | |
""" | |
Scan the matplotlib examples page and open the 1.5.1 version and | |
2.0.0b2 version | |
""" | |
old_page = requests.get(old_url+'index.html').text | |
old_tree = html.fromstring(old_page) | |
examples = old_tree.xpath('//a[@class="reference internal"]') | |
for ex in examples: | |
if 'index.html' in ex.attrib['href']: | |
continue | |
tmp=[skip for skip in skip_these if skip in ex.attrib['href']] | |
if len(tmp)>0: | |
continue | |
subprocess.call(['google-chrome', | |
old_url+ex.attrib['href'], | |
new_url+ex.attrib['href']]) | |
input("%s - Press Enter to continue..." % (ex.attrib['href'],)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment