0

I am trying to create a scraper in Python which sends json.load requests and pull the required data.

The webpage I'm trying to scrape has a search box which passes the json data after encrypting the input value. I'm able to achieve that, but I had to manually pass the encrypted input value to the request.

After some paying around with the developer options, I was able to find the javascript code that is encrypting the input value

function EncryptionCode(value){
    var wrenchK = RSA.enc.Utf8.bufferParse(Base64.decode(Const.wrench));
        var response = RSA.SYMM.encrypt(RSA.enc.Utf8.parse(value), wrenchK,
            {
                keySize: 128 / 8,
                iv: wrenchK,
                mode: RSA.mode.CBC,
                padding: RSA.pad.Pkcs7
            });
    return response;

This code encrypts a given string as follows: Example String: Cipla Ltd. Encrypted string passed to JSON:

7Tx7+WkQdeTJogipi8RK4TNQ7O23RQ39AVCv0Lc/3KMqpGGL2UTLgMzrKZKiSF9FomOPOYOBlTmBYgnI1t7uT3mcRsd04lJlwpeKs0GZJH1LMLBJGqUxV1hvPzrA3A4W8gNAUjRVpj1K4OvWAWwwog==

Kindly suggest how can I make this encryption directly in Python so that I don't have to hardcode the encrypted input value for every query.

Thanks

  • This might help: https://stackoverflow.com/questions/8284765/how-do-i-call-a-javascript-function-from-python – M.Soyturk Jul 21 '20 at 21:02
  • If you are using Selenium, you can refer to this one: https://stackoverflow.com/questions/14088541/how-to-execute-a-javascript-function-in-python-with-selenium – M.Soyturk Jul 21 '20 at 21:04
  • There isn't nearly enough information in this question to answer it. Remember, we aren't looking at the web page in question, so we don't know what the `RSA` class is or does. – President James K. Polk Jul 22 '20 at 11:59

0 Answers0