I've created a script to scrape content from a webpage. When I navigate to the aforementioned link, I can see the total listing displayed as Results (10080). This number varies each time I refresh the page.
I can generate the number of results using the script below. To do this, though, I need to copy the values of l and area from devtools and use them as parameters while issuing post requests.
For total listings:
url = 'https://www.rentfaster.ca/api/map.json'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
}
params = {
'l': '4,54.9773,-112.766',
'area': '59.68965038087162,-91.935921875,49.63882324278784,-133.596078125',
'exclude': ''
}
res = requests.post(url,data=params,headers=headers)
print(res.json()['total'])
What I can't understand is how the values of l and area are generated, and how can I retrieve them using the script? To be specific, when I go for the city-wise listings, as in Calgary, AB, I also need to use values of l and area as parameters while sending post requests.
For city-wise listings:
url = 'https://www.rentfaster.ca/api/map.json'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
}
params = {
'l': '13,51.0452,-114.0764',
'area': '51.058053440451424,-114.0356853316207,51.03236736163589,-114.11705282429648',
'e': 'zoom_changed',
'exclude': ''
}
res = requests.post(url,data=params,headers=headers)
print(res.json())
Question: How can I find the values of
landareathat are used as parameters while issuing post requests?
from Can't find the values of certain keys that are used as parameters while issuing post requests
No comments:
Post a Comment