Skip to content

Instantly share code, notes, and snippets.

@jackfischer
Created February 12, 2017 21:09
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 jackfischer/1fbb7b2c7938dfcc196a6e15e7312020 to your computer and use it in GitHub Desktop.
Save jackfischer/1fbb7b2c7938dfcc196a6e15e7312020 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import requests
states = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']
for state in states:
stateselection = "http://www.icee.com/locationsICEE.asp?state=%s" % state
r = requests.get(stateselection)
soup = BeautifulSoup(r.text, "html.parser")
rows = soup.find_all("option")
cities = [row.attrs['value'] for row in rows]
for city in cities:
data = {'city': city, 'state': state, 'submit': 'submit'}
url = "http://www.icee.com/locationsresults.asp"
r = requests.get(url, data=data)
soup = BeautifulSoup(r.text, "html.parser")
rows = soup.find_all(class_="order_table2")
i = 6
while i < len(rows):
print(rows[i].text + rows[i+1].text)
i += 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment