def get_counties_by_state(state): search = SearchEngine(simple_zipcode=True) counties = [] #res = search.query(city="Fairfax", state="VA") res = search.by_state(state=state, sort_by='zipcode', returns = 50) for zip in res: counties.append(zip.county) return counties
def get_zipcode(state): zipcodes = [] search = SearchEngine() res = search.by_state(state, returns=None) for i in range(len(res)): zipcodes.append(res[i].zipcode) return zipcodes
from uszipcode import SearchEngine search = SearchEngine(simple_zipcode=False) zipcode = search.by_state("Florida",returns=1000) for curZip in zipcode: print(curZip.polygon)
from uszipcode import SearchEngine, SimpleZipcode, Zipcode from radar import RadarClient import googlemaps import requests import mongo import threading #uszipcode zipcode collection search = SearchEngine() res = search.by_state("California", returns=1601) coords = [] for r in res: coords += [(r.zipcode, r.lat, r.lng)] #API keys radar = RadarClient('API KEY') maps = googlemaps.Client(key='API KEY') src = mongo.connectMongo() #mongo data collection storage forUpload = [] def addData(list, forUpload): print(list) for c in list: ser = (c[1], c[2]) search = radar.search.places(near=ser, categories=[
from selenium.common.exceptions import NoSuchElementException driver = webdriver.Chrome("./chromedriver") find = driver.find_element_by_xpath name_in = "/html/body/form/div[4]/div/div[1]/div/div[1]/div[1]/ul/li[1]/input" # "/html/body/form/div[2]/div[1]/div[1]/div[1]/fieldset[1]/table/tbody/tr[2]/td[1]/input" zip_in = "/html/body/form/div[4]/div/div[1]/div/div[1]/div[1]/ul/li[4]/input" # "/html/body/form/div[2]/div[1]/div[1]/div[1]/fieldset[1]/table/tbody/tr[3]/td[3]/input" search_btn = "/html/body/form/div[2]/div[1]/div[1]/div[1]/fieldset[1]/table/tbody/tr[4]/td[2]/button" search_btn_2 = " results = "/html/body/form/div[2]/div[1]/div[1]/div[1]/fieldset[2]/table[2]/tbody/tr[1]" export_btn = "/html/body/form/div[2]/div[1]/div[1]/div[1]/fieldset[2]/table[1]/tbody/tr[1]/td[2]/button" error_msg = "/html/body/div[1]/div[2]/div" close_btn = "/html/body/div[1]/div[2]/center/input" search = SearchEngine(simple_zipcode=True) for zc in search.by_state("florida", returns=-1): # driver.get("https://ocrdata.ed.gov/DistrictSchoolSearch#schoolSearch") driver.get("https://ocrdata.ed.gov/flex/Reports.aspx?type=school") find(name_in).send_keys("\b\b\b\bhigh") find(zip_in).send_keys(f"\b\b\b\b\b{zc.zipcode}") find(search_btn).click() time.sleep(2) try: find(results) find(export_btn).click() print(f"successful export for zipcode {zc.zipcode}") except NoSuchElementException as nsee: print(f"error: did not find anything for zipcode {zc.zipcode}") print(f"error: {find(error_msg).text}")
elif "second" in unit_v: return current_time - datetime.timedelta(seconds=int(time_v)) elif "day" in unit_v: return current_time - datetime.timedelta(days=int(time_v)) elif "hour" in unit_v: return current_time - datetime.timedelta(hours=int(time_v)) else: print(f"time unit not in consider {unit_v}") raise IndexError for state in states: df_list = [] res = search.by_state(state, returns=0) for i, zip_value in enumerate(res): print(f"Processing {zip_value.zipcode} in {state} {i}") while True: try: test = requests.get( "https://www.gasbuddy.com/home?search=%d&fuel=1" % (int(zip_value.zipcode)), headers=headers) break except Exception as e: continue