So my code below seems to run fine but I get no output. The factor that makes it stop working is when I run arange with a 000.0001 interval. When I do a normal for range where it goes by 1 I get an output. My goal is to get back all the store locations of circle K and other convenience stores that the rename themselves in local regions of Canada. If anyone can point out the issue that would be great!
import requests
import json
import numpy as np
import csv
lat_lng = [(lat,long) for lat,long in zip(np.arange(42,84,0.0001),np.arange(-142,-52,0.0001))]
for latitude,longitude in lat_lng:
url = f"https://www.circlek.com/stores_new.php?lat={latitude}&lng={longitude}&services=®ion=global"
payload={}
headers = {
'Connection': 'keep-alive',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
'Accept': '*/*',
'X-Requested-With': 'XMLHttpRequest',
'sec-ch-ua-mobile': '?0',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://www.circlek.com/store-locator?Canada&lat=43.6529&lng=-79.3849',
'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8',
'dnt': '1'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.json())
What sprung in my eye is that you're using a negative step for numpy.arange to express the distance between two adjacent values, out[i+1] - out[i]
. as stop is after - and not before - a start, and as the interval does not include a stop value it does also not include this start value with this step.
this interval might appear flawed and the iterations then not working.
however as start is below stop and stop never is part, the range should be expected as what it is: empty.
as that range construes each tuples right hand side, there shouldn't be any tuples and therefore nothing to iterate over.
negating the step might turn this into a more expected result already.