D
D
DoggieMurr2022-02-05 17:16:55
Parsing
DoggieMurr, 2022-02-05 17:16:55

How to parse by car brand?

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"))

I found this bidfax.info site parser on overflow, since encryption keys are used there.
The question is that this parser would work not according to the VIN code, but according to the brand of the car that the user enters

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gurucode, 2022-02-16
@gurucode

I have a question, how to get around the error "Congratulations! You are permanently blocked on our site.", I even connected a Tor proxy for this, but without it being useful for anyone to block.
Another interesting point, according to this code, it is possible to get data from the site, of course, until you are blocked, but the moment the proxy server is connected

session.get(parse_url, proxy="socks5://localhost:9150")

again gives the old error that "You need to enable JS support in your browser to visit this site." and if you remove the proxy completely it works fine!!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question