Answer the question
In order to leave comments, you need to log in
How to add parameters to python requests url from file?
How to implement the addition of the id of the goods from the file to the url parameters of the request?
In the file, product ids are presented as a comma-separated list.
In the proposed code snippet, the id is added manually.
def get_product_data():
payload = {'product_ids': '89673362,107781996,55500408,55500438,55435122,55500420,176962934,176962906'}
#response = requests.get(url)
f = requests.get('https://example.com/get?', params=payload)
d = f.json()
return d
Answer the question
In order to leave comments, you need to log in
If I understand correctly, then you can do something like this:
def get_product_data():
with open('id.txt') as file:
id = file.readlines()
payload = {'product_ids': id}
f = requests.get('https://xl-catalog-api.rozetka.com.ua/v2/goods/getDetails?', params=payload)
d = f.json()
return d
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question