Created
May 24, 2014 01:40
-
-
Save alecxe/927a6aa999826f8b56f7 to your computer and use it in GitHub Desktop.
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 | |
from bs4 import BeautifulSoup | |
base_url = "http://www.boostmobile.com/stores/?page={page}&zipcode={zipcode}" | |
num_pages = 10 | |
zipcodes = [30008, 30009] | |
for zipcode in zipcodes: | |
print "Zip Code: %s" % zipcode | |
for page in xrange(1, num_pages + 1): | |
url = base_url.format(page=page, zipcode=zipcode) | |
soup = BeautifulSoup(urllib2.urlopen(url)) | |
print "Page Number: %s" % page | |
results = soup.find('table', class_="results") | |
for h2 in results.find_all('h2'): | |
print h2.text | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment