Skip to content

Instantly share code, notes, and snippets.

@ayushgoel
Created September 19, 2015 09:36
Show Gist options
  • Save ayushgoel/f8895bdedda8e9363152 to your computer and use it in GitHub Desktop.
Save ayushgoel/f8895bdedda8e9363152 to your computer and use it in GitHub Desktop.
# coding: utf-8
#!/usr/bin/env python
import urllib2, re, os
#from BeautifulSoup import BeautifulSoup
#import simplejson as json
import json
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
def fetchPage(url):
req = urllib2.Request(url)
req.add_header('User-Agent', user_agent)
response = urllib2.urlopen(req)
html = response.read()
response.close()
return html
html = fetchPage("http://alltheragefaces.com/api/face/6")
print html
jsonData = json.JSONDecoder().decode(html)
print jsonData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment