Skip to content

Instantly share code, notes, and snippets.

@sauravtom
Last active December 12, 2015 03:28
Show Gist options
  • Save sauravtom/4707392 to your computer and use it in GitHub Desktop.
Save sauravtom/4707392 to your computer and use it in GitHub Desktop.
Making a web scraper in python
#-------------------------------------------------------
import urllib2
import json as simplejson
response = urllib2.urlopen('https://twitter.com/')
html=response.read()
print html
#--------------------------------------------------------
#using Request instead of urlopen as we can do a lot of things in request, like GET , POST request, on either HTTP of ftp clients
import urllib2
import json as simplejson
req = urllib2.Request('http://news.ycombinator.com/news')
response = urllib2.urlopen(req)
the_page = response.read()
print the_page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment