import requests
import re
ptoids = [72445]
for ptoid in ptoids:
s = requests.Session()
r = s.get('http://oto-register.autoins.ru/pto/index.xhtml')
cdata = re.search(r'id="j_id1:javax.faces.ViewState:0" value="(.+?)"', r.text).group(1).strip()
data = {
'javax.faces.partial.ajax': 'true',
'javax.faces.source': 'mainForm:remoteCommandSetupPtoId_action',
'javax.faces.partial.execute': 'mainForm:remoteCommandSetupPtoId_action',
'javax.faces.partial.render': 'mainForm:contentTabsPanel mainForm:ptoPanel',
'mainForm:remoteCommandSetupOtoId_action': 'mainForm:remoteCommandSetupPtoId_action',
'ptoId': ptoid,
'mainForm': 'mainForm',
'mainForm:j_idt8': ptoid,
'mainForm:j_idt9': '',
'mainForm:j_idt10': '',
'mainForm:j_idt11': '',
'javax.faces.ViewState': cdata,
}
headers = {
'X-Requested-With': 'XMLHttpRequest',
'Faces-Request': 'partial/ajax',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
}
r = s.post('http://oto-register.autoins.ru/pto/index.xhtml', data=data, headers=headers)
print(r.text)
import requests
import re
from bs4 import BeautifulSoup
import pandas as pd
import io
otoids = []
for i in range(105, 111):
i
otoids.append(i)
for otoid in otoids:
s = requests.Session()
r = s.get('http://oto-register.autoins.ru/oto/index.xhtml')
cdata = re.search(r'id="j_id1:javax.faces.ViewState:0" value="(.+?)"', r.text).group(1).strip()
data = {
'javax.faces.partial.ajax': 'true',
'javax.faces.source': 'mainForm:remoteCommandSetupOtoId_action',
'javax.faces.partial.execute': 'mainForm:remoteCommandSetupOtoId_action',
'javax.faces.partial.render': 'mainForm:contentTabsPanel mainForm:otoPanel',
'mainForm:remoteCommandSetupOtoId_action': 'mainForm:remoteCommandSetupOtoId_action',
'otoId': otoid,
'mainForm': 'mainForm',
'mainForm:j_idt8': otoid,
'mainForm:j_idt9': '',
'mainForm:j_idt10': '',
'mainForm:j_idt11': '',
'javax.faces.ViewState': cdata,
}
headers = {
'X-Requested-With': 'XMLHttpRequest',
'Faces-Request': 'partial/ajax',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
}
r = s.post('http://oto-register.autoins.ru/oto/index.xhtml', data=data, headers=headers)
ogrn = re.search(r'ОГРН/ОГРНИП</div>\n.+<p>(.+?)</p>', r.text)
if ogrn != None:
ogrn = ogrn.group(1)
else:
ogrn = 'None'
import requests
from bs4 import BeautifulSoup
import pandas as pd
headers = {'Accept' : 'application/xml, text/xml, */*; q=0.01', 'Accept-Encoding' : 'gzip, deflate', 'Accept-Language' : 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', 'Connection' : 'keep-alive', 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8', 'Cookie' : 'JSESSIONID=0AEF6E056E59E73D8CD49CE483409BAA', 'Faces-Request' : 'partial/ajax', 'Host' : 'oto-register.autoins.ru', 'Origin' : 'http://oto-register.autoins.ru', 'Referer' : 'http://oto-register.autoins.ru/oto/', 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', 'X-Requested-With' : 'XMLHttpRequest'}
params = {'javax.faces.partial.ajax' : 'true', 'javax.faces.source' : 'mainForm:remoteCommandSetupOtoId_action', 'javax.faces.partial.execute' : 'mainForm:remoteCommandSetupOtoId_action', 'javax.faces.partial.render' : 'mainForm:contentTabsPanel mainForm:otoPanel', 'mainForm:remoteCommandSetupOtoId_action' : 'mainForm:remoteCommandSetupOtoId_action', 'otoId' : '11125', 'mainForm' : 'mainForm', 'javax.faces.ViewState' : '-6658669341351508882:-4048211535286556869'}
url = 'http://oto-register.autoins.ru/oto/index.xhtml'
r = requests.post(url, headers = headers, params = params).json()
А как модернизировать код, чтобы исключить дополнительно список дат?