Skip to content

Instantly share code, notes, and snippets.

@alecxe
Created May 24, 2014 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecxe/927a6aa999826f8b56f7 to your computer and use it in GitHub Desktop.
Save alecxe/927a6aa999826f8b56f7 to your computer and use it in GitHub Desktop.
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
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment