Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Loops over examples on the matplotlib1.5.1 page and opens the 1.5.1 and 2.0 version in a browser
#!/usr/bin/env python
import requests
import subprocess
from lxml import html
old_url = ''
new_url = ''
# 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']:
tmp=[skip for skip in skip_these if skip in ex.attrib['href']]
if len(tmp)>0:
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