Created
May 7, 2014 14:55
-
-
Save arafatkamaal/c6a4501c9b5ef7dd6117 to your computer and use it in GitHub Desktop.
Scraper
This file contains hidden or 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
# | |
# This program scrapes the FIFA Data from the site: | |
# http://thesoccerworldcups.com/index.php | |
# | |
# | |
import urllib2 | |
##################################################################### | |
# Implementation of classes starts here # | |
##################################################################### | |
##################################################################### | |
# Implementation of functions starts here # | |
##################################################################### | |
def get_page( url ): | |
if not url: | |
return False | |
try: | |
request = urllib2.Request( url ) | |
response = urllib2.urlopen( request ) | |
data = response.read() | |
return data | |
except urllib2.HTTPError as e: | |
print "The url" + url + "returned with error code " + e.code + " and " + e.read() | |
return False | |
##################################################################### | |
# Main function # | |
##################################################################### | |
get_page( 'http://www.google.com' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment