如何从 csv 数据循环 HTTPS requests.post
How to loop a HTTPS requests.post from csv data
我想循环 post 来自 csv 的数据请求。
csv 文件(有 2 列)=
agentLicenseID(x) licenseExpirationDate(y)
271844 6/20/2021
271847 6/30/2021
271848 5/21/2021
body = {'sid':API_SID,'key':API_KEY, 'agentLicenseID':x,'licenseExpirationDate':y }
response = requests.post(url=UPD_URL,data=body)
我打算从 csv 文件循环响应不同的 x 和 y 值(agentLicenseID 和 licenseExpirationDate)
在pandas
的帮助下:
import pandas as pd
df = pd.read_csv("your_file.csv", sep=r"\s+") # <-- change the separator if it's different
for x, y in zip(df["agentLicenseID"], df["licenseExpirationDate"]):
body = {
"sid": API_SID,
"key": API_KEY,
"agentLicenseID": x,
"licenseExpirationDate": y,
}
response = requests.post(url=UPD_URL, data=body)
# ...
我想循环 post 来自 csv 的数据请求。
csv 文件(有 2 列)=
agentLicenseID(x) licenseExpirationDate(y)
271844 6/20/2021
271847 6/30/2021
271848 5/21/2021
body = {'sid':API_SID,'key':API_KEY, 'agentLicenseID':x,'licenseExpirationDate':y }
response = requests.post(url=UPD_URL,data=body)
我打算从 csv 文件循环响应不同的 x 和 y 值(agentLicenseID 和 licenseExpirationDate)
在pandas
的帮助下:
import pandas as pd
df = pd.read_csv("your_file.csv", sep=r"\s+") # <-- change the separator if it's different
for x, y in zip(df["agentLicenseID"], df["licenseExpirationDate"]):
body = {
"sid": API_SID,
"key": API_KEY,
"agentLicenseID": x,
"licenseExpirationDate": y,
}
response = requests.post(url=UPD_URL, data=body)
# ...