How to “log in” to a website using Python's Requests module?

前端 未结 6 1748
别那么骄傲
别那么骄傲 2020-11-22 02:48

I am trying to post a request to log in to a website using the Requests module in Python but its not really working. I\'m new to this...so I can\'t figure out if I should ma

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 03:07

    If the information you want is on the page you are directed to immediately after login...

    Lets call your ck variable payload instead, like in the python-requests docs:

    payload = {'inUserName': 'USERNAME/EMAIL', 'inUserPass': 'PASSWORD'}
    url = 'http://www.locationary.com/home/index2.jsp'
    requests.post(url, data=payload)
    

    Otherwise...

    See https://stackoverflow.com/a/17633072/111362 below.

提交回复
热议问题