我曾经在网络上找到form_data列表,然后发送POST请求,但是在这种情况下,除了我拿requestspays以外,没有其他事情。因此,似乎该方法无效。
The input:
这是我尝试过的代码:import requests
from bs4 import BeautifulSoup
import csv
import json
request_headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en,en-GB;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '50',
'Content-Type': 'application/json;charset=UTF-8',
'Cookie': 'ETAXES=etaxes; JSESSIONID=C033E796031CA5C84A3A7B38E24330D4',
'Host': 'www.e-taxes.gov.az',
'Origin': 'https://www.e-taxes.gov.az',
'Referer': 'https://www.e-taxes.gov.az/ebyn/vergiBorcu.html',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/75.0.3770.142 Safari/537.36',
}
taxid = {
'8400260181',
'1700393071',
'1004199751',
'2002283071',
}
payloads = {"METHOD": "wsEbynGetDebetSum",
"voen": taxid,
}
url = 'https://www.e-taxes.gov.az/ebyn/vergiBorcu.html'
for voen in taxid:
payloads['voen'] = voen
response = requests.post(url, data=json.dumps(payloads), headers=request_headers)
s = BeautifulSoup(response.content, 'lxml')
sContent = s.find('div', class_="col-sm-3").find_all("input", class_="form-control ng-pristine")
print(voen)
print(sContent)
with open('taxDebt.csv', 'w', newline='', encoding='utf-8') as myfile:
writer = csv.writer(myfile, quoting=csv.QUOTE_ALL, delimiter="\n")
writer.writerow(sContent)
我希望得到类似Debt: "value"的输出,但它返回空列表:1700393071
[]
1004199751
[]
8400260181
[]
2002283071
[]