JavaScript
x
20
20
1
i_ucprice = [[id, price], [id, price], [id, price], [id, price]]
2
3
for ids in id_ucprice:
4
post_data = {
5
'price': ids[1],
6
'overpriced_email_price_change': False,
7
'apply_to_all': False,
8
}
9
for i in range(ids[0]):
10
response = requests.post('api{ids[0]}/pricing', cookies=cookies, headers=headers, json=post_data)
11
update_data = json.loads(response.text)
12
print(update_data)
13
response_price = update_data['priceCents']
14
r_item = update_data['name']
15
r_id = update_data['id']
16
ids[0]
17
18
if response_price == ids[1]:
19
print(style.MAGENTA + f'[{datetime.now()}] => Updated Price: {response_price/100:.2f} | ID: {r_id} | Item: {r_item}')
20
I have an nested list that works as [[id, price], [id, price], [id, price], [id, price]]
and I need to iterate through the [0]
and the [1]
value to use in the request url and json data respectively. I can’t get the variable to be used in the request url but the json data seems to work fine
Advertisement
Answer
have you tried making the url f-string?
JavaScript
1
2
1
response = requests.post(f'api{ids[0]}/pricing', cookies=cookies, headers=headers, json=post_data)
2