[Python] Troubleshoot a simple Python code to input data and scrape output result from a...

Discussão em 'Python' iniciado por Stack, Fevereiro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am no programmer, just generated this code using ChatGPT and some basic logic my little brain understands.

    I want to input a PSSH value into a website, it has only one input field in it. When pressed the Send button, it generates an output, which I want to scrape and display in my console.

    Website: https://cdrm-project.com/findpssh PSSH: AAAAQXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACEIARIQriPE7lcBTSieCCGtu9/r+SIJNDAwMDAwOTc1OAA=

    When done manually on the website, the output box displays the desired result which is "Cached PSSH..." When executed the below python code, the python code does successfully scrape the output, but the output is "Not Found" which happens when we input a wrong value on that website field.

    Here's the code:

    import requests

    # Set the URL of the website

    url = "https://cdrm-project.com/findpssh"

    # Set the PSSH value to input

    pssh_value = "AAAAQXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACEIARIQriPE7lcBTSieCCGtu9/r+SIJNDAwMDAwOTc1OAA="

    # Set the data to send in the POST request

    payload = {'pssh': pssh_value}

    # Send the POST request to the website and get the response

    response = requests.post(url, data=payload)

    # Extract the result from the response content

    result = response.content.decode()

    # Print the result in the console

    print(result)\

    Continue reading...

Compartilhe esta Página