Last active
December 12, 2015 03:28
-
-
Save sauravtom/4707392 to your computer and use it in GitHub Desktop.
Making a web scraper in python
This file contains 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
#------------------------------------------------------- | |
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