from bs4 import BeautifulSoup
import aiohttp
import asyncio
import js2py
headers = {
'Host': 'bidfax.info',
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/94.0.4606.71 Safari/537.36",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,"
"application/signed-exchange;v=b3;q=0.9",
"Accept-Language": "accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
"Accept-Encoding": "gzip, deflate, br",
"DNT": "1",
"Connection": "close",
"Upgrade-Insecure-Requests": "1",
"Cache-Control": "max-age=0",
}
token2 = js2py.eval_js("""
function randomString(len) {
var str = "";
for (var i = 0; i < len; i++) {
var rand = Math.floor(Math.random() * 62);
var charCode = rand += rand > 9 ? (rand < 36 ? 55 : 61) : 48;
str += String.fromCharCode(charCode);
}
return str;
}
""")
async def test(vin):
url = "https://bidfax.info/"
aes_js = "https://bidfax.info/aes.min.js"
parse_url = f"https://bidfax.info/?do=search&subaction=search&story={vin}&token2={token2(463)}&action2=search_action"
async with aiohttp.ClientSession(headers=headers) as session:
async with session.get(url) as response:
script = BeautifulSoup(await response.text(), "html.parser").find_all("script")[1].get_text()
response = await session.get(aes_js)
slowAES = await response.text()
jslogic = script.split('document.cookie="')[0]
FORT = js2py.eval_js(slowAES + jslogic + " toHex(slowAES.decrypt(c,2,a,b));")
searchkey = "5YJ3E1EA0JF042788" # сюда нужно вставить searchkey
session.headers.update({"Cookie": "FORT=" + FORT + "; searchkey=" + searchkey})
res = await session.get(parse_url)
with open("file.html", "w", encoding="UTF-8") as file:
file.write(await res.text())
loop = asyncio.get_event_loop()
loop.run_until_complete(test("5YJ3E1EA0JF042788"))
Нашел на оверфлов данный парсер сайта bidfax.info так как там используются ключи шифрования.
Вопрос состоит в том что бы данный парсер работал не по вин-коду, а по марке автомобиля которую введет пользователь