Skip to content

Instantly share code, notes, and snippets.

@KHwong12
Created March 7, 2019 21:21
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 KHwong12/141e341e733062c89f2864a938543cea to your computer and use it in GitHub Desktop.
Save KHwong12/141e341e733062c89f2864a938543cea to your computer and use it in GitHub Desktop.
def main():
"""
Get the details of the shop by brute-force searching the id of the shop
"""
# Approximate minimum and maximum storeid are searched manually
storeid_min = 2050
storeid_max = 2600
outFile = 'nakau_rawdata.csv'
# Keys from the get_data function
headers = ['storeid','brand','name','lat','lon','postalCode','address',
'business_hour1','business_hour2','business_hour3']
with open(outFile, 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, delimiter=',', lineterminator='\n',fieldnames=headers)
# Write the headers
writer.writeheader()
for storeid in range(storeid_min,storeid_max+1):
print(f"Processing {storeid}...")
store_row = get_data_sukiya(storeid)
if store_row == None:
print(f"failed to request the page with storeid {storeid}")
continue
writer.writerow(store_row)
csvfile.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment