如果您查看“网络”选项卡并右键单击网络请求,然后选择“复制 -> 复制为 cURL”,您会得到如下内容:
curl 'https://pjd.tjgo.jus.br/BuscaProcessoPublica' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Origin: https://pjd.tjgo.jus.br' -H 'X-Requested-With: XMLHttpRequest' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' -H 'Sec-Fetch-Site: same-origin' -H 'Sec-Fetch-Mode: cors' -H 'Referer: https://pjd.tjgo.jus.br/BuscaProcessoPublica?PaginaAtual=2&Passo=7' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9' -H 'Cookie: WIDPJP=.cp03-1:cp03-1; style=null; JSESSIONID=kMiu0qC-d11BAdWVd6QoJM837YUXuTsWVgTofjLk.cp03:server-cp03-1' --data 'chamadaAjax=true&tabela=1&offset=0&PassoEditar=12&consultaPronta=true&' --compressed
然后,您可以使用https://curl.trillworks.com/之类的工具作为一种简单的方法将其从 cURL 格式转换为请求格式,并最终得到
cookies = {
'WIDPJP': '.cp03-1:cp03-1',
'style': 'null',
'JSESSIONID': 'kMiu0qC-d11BAdWVd6QoJM837YUXuTsWVgTofjLk.cp03:server-cp03-1',
}
headers = {
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Origin': 'https://pjd.tjgo.jus.br',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Referer': 'https://pjd.tjgo.jus.br/BuscaProcessoPublica?PaginaAtual=2&Passo=7',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9',
}
data = {
'chamadaAjax': 'true',
'tabela': '1',
'offset': '0',
'PassoEditar': '12',
'consultaPronta': 'true',
'': ''
}
response = requests.post('https://pjd.tjgo.jus.br/BuscaProcessoPublica', headers=headers, cookies=cookies, data=data)
# Edit: If you want to get all the pages of data, you can do something like this:
response = requests.post('https://pjd.tjgo.jus.br/BuscaProcessoPublica', headers=headers, cookies=cookies, data=data)
TOTAL = response.json()['total']
offset = 0
values = []
while offset < TOTAL:
data['offset'] = str(offset)
response = requests.post('https://pjd.tjgo.jus.br/BuscaProcessoPublica', headers=headers, cookies=cookies, data=data)
rows = response.json()['rows']
offset += len(rows)
values += rows