Created
June 24, 2013 09:14
-
-
Save voldyman/5848780 to your computer and use it in GitHub Desktop.
Simple python API 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
from BeautifulSoup import BeautifulSoup | |
from urllib2 import urlopen | |
def get_page(pageToScrape): | |
return urlopen(pageToScrape).read() | |
def main(): | |
pagesToScrape = ['http://example.com/data1/api.xml' , 'http://example.com/data2/api.xml'] | |
for page in pagesToScrape: | |
content = get_page(page) | |
parsedContent = BeautifulSoup(content) | |
for data in parsedContent.findAll('info'): | |
print data | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment