Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A snippet of code from the Washington Post's internal story API to process iframes.
# And now we get into the fun rando ones
# First up, vevo! https://www.eff.org/https-everywhere/atlas/domains/vevo.com.html
elif 'http://cache.vevo.com/' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://cache.vevo.com/', 'https://scache.vevo.com/')
# Next up YouTube
elif 'http://www.youtube.com/' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://www.youtube.com/', 'https://www.youtube.com/')
# Gfycat http://gfycat.com
elif 'http://gfycat.com' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://gfycat.com/', 'https://gfycat.com/')
elif 'http://www.dailymotion.com' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://www.dailymotion.com', 'https://www.dailymotion.com')
elif 'http://apps.washingtonpost.com' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://apps.washingtonpost.com', '//www.washingtonpost.com/apps/')
elif 'http://data-wrapper.s3.amazonaws.com' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://data-wrapper.s3.amazonaws.com', 'https://data-wrapper.s3.amazonaws.com')
elif 'http://www.washingtonpost.com/wp-srv/graphics/' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://www.washingtonpost.com/wp-srv/graphics/', '//www.washingtonpost.com/wp-srv/graphics/')
elif 'http://www.washingtonpost.com/graphics/' in iframe['src']:
iframe['src'] = iframe['src'].replace('http://www.washingtonpost.com/graphics/', '//www.washingtonpost.com/graphics/')
elif '//cdnapisec.kaltura.com/' in iframe['src']:
iframe.decompose()
elif 'http://' in iframe['src']:
iframe.decompose()

kura commented Dec 13, 2015

Use a mapper... =(

You could just remove the "http:" part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment