Python send POST with header

前端 未结 3 1396
独厮守ぢ
独厮守ぢ 2020-12-02 16:10

I try to build a python script who sends a POST with parameters for extracting the result. With fiddler, I have extracted the post request who return that I want. The websit

3条回答
  •  时光取名叫无心
    2020-12-02 17:00

    To make POST request instead of GET request using urllib2, you need to specify empty data, for example:

    import urllib2
    req = urllib2.Request("http://am.domain.com:8080/openam/json/realms/root/authenticate?authIndexType=Module&authIndexValue=LDAP")
    req.add_header('X-OpenAM-Username', 'demo')
    req.add_data('')
    r = urllib2.urlopen(req)
    

提交回复
热议问题