[英]How to make a get request with each value in an entire array
def get_listing_ids():
response = requests.get('apiurl', params=params, cookies=cookies, headers=headers)
response_data_ids = response.json()
listing_ids = [result['id'] for result in response_data_ids['results']]
if response.status_code == 200:
print(f'[{datetime.now()}] => got listing ids[{response.status_code}]')
else:
print(f'error getting listing ids[{response.status_code}][{response}]')
get_listing_ids()
def check_listing_prices(listing_ids):
response = requests.get(f'apiurl/{result['id']}' for result in response_data['results']', cookies=cookies, headers=headers)
print(response.status)
check_listing_prices(listing_ids)
因此,我的代码使用了一个 get 请求,该请求返回一个 json,但将键值格式化为当前正在工作的数组。 我的下一个问题是,我希望该数组中的每个值都位于新函数中另一个获取请求 url 的末尾(或者我可以将它保留在同一个函数中吗?我不是 100% 确定)然后将打印每个特定的键值,而不是将其放入数组中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.