-1

Now before this gets marked as duplicate and downvoted, I've tried all the other links like (see below) and they don't help.

converting curl call to python requests

Convert cURL request to Python-Requests request

the cURL call i'm making is (Theres $ interpolation as its in an .sh file)

COOKIE_JAR=./program.cookies
LOGIN_URL= 'URL'
USER_ID = 'USERID'
PASSWORD = 'password'
VIEWSTATE = 'long string of text'

$(curl"$LOGIN_URL"-L -b "$COOKIE_JAR" -c "$COOKIE_JAR"
--data-urlencode "__VIEWSTATE=$viewstate" --data-urlencode "userid=$USER_ID" 
--data-urlencode "password=$PASSWORD") || printf >2 "failed to get token:\n%s" 
"$token" && printf "your token is:\n%s\n" "$token"

How can i translate this to the python requests form? Any help will be greatly appreciated!! :)

Community
  • 1
  • 1
Wboy
  • 2,452
  • 2
  • 24
  • 45

1 Answers1

0

So I managed to get it working, if anyone needs it:

 payload = {
        'userid': USERID,
        'password': PASSWORD,
        '__VIEWSTATE':viewstate # defined earlier
    }
    with requests.Session() as s:
        x = s.get(URL, params=payload,headers=headers)
        token = x.text

Didn't need the cookies after all!

Wboy
  • 2,452
  • 2
  • 24
  • 45