如何在python请求中传递表单数据时避免无效输入错误?
我正在使用Python2.7将post请求发送到带有我的客户号的网站,以获取其详细信息 我在传递以下请求时收到无效输入错误。 我还尝试使用json编码的表单数据如何在python请求中传递表单数据时避免无效输入错误?,python,json,python-2.7,web-scraping,python-requests,Python,Json,Python 2.7,Web Scraping,Python Requests,我正在使用Python2.7将post请求发送到带有我的客户号的网站,以获取其详细信息 我在传递以下请求时收到无效输入错误。 我还尝试使用json编码的表单数据 url="https://pgi.billdesk.com/pgidsk/pgmerc/rvvnlaj/RVVNLAJConfirm.jsp" payload={ "service":"BILL", "txtCustomerID":"110331033880", "txtEmail":"
url="https://pgi.billdesk.com/pgidsk/pgmerc/rvvnlaj/RVVNLAJConfirm.jsp"
payload={
"service":"BILL",
"txtCustomerID":"110331033880",
"txtEmail":"mymailid@gmail.com"
}
headers={
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"Accept-Encoding":"gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
"Upgrade-Insecure-Requests": "1",
"Content-Type":"application/x-www-form-urlencoded",
"Connection":"keep-alive",
"Host":"pgi.billdesk.com"
}
z=requests.post(url,headers=headers,data=payload)
print z.content
我期待内容中的账单详细信息,但我收到无效输入错误
<td > </td>
<td bgcolor="#ff9966" class="textrvvnl">Invalid Inputs</td>
<td > </td>
</tr>
<tr>
<td > </td>
<td bgcolor="#ff9966" class="textrvvnl">
</td>
<td > </td>
</tr>
请告知我是否以不正确的格式传递表单数据。如果您使用了错误的标题,请尝试使用以下标题:
headers={
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0",
"Referer": "https://pgi.billdesk.com/pgidsk/pgmerc/rvvnlaj/RVVNLAJDetails.jsp"
}
希望这有帮助