Python : Trying to POST form using requests

后端 未结 3 1329
忘掉有多难
忘掉有多难 2020-11-29 03:37

I\'m trying to login a website for some scraping using Python and requests library, I am trying the following (which doesn\'t work):

import requests
headers          


        
3条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 03:45

    Send a POST request with content type = 'form-data':

    import requests
    files = {
        'username': (None, 'myusername'),
        'password': (None, 'mypassword'),
    }
    response = requests.post('https://example.com/abc', files=files)
    

提交回复
热议问题