1

我正在尝试使用 python 请求模块登录 Quora。我使用 firebug 分析了网站的发布请求,以下是发送的数据:

*

json    {"args":[],"kwargs":{"email":"userid@email.com","password":"somePassowrd","passwordless":1}}
formkey e50a4be87e84731aea6f9c806957d7d0
postkey df81f33e60422d6bfbe023b35b2e5ba9
window_id   dep3508-955450102918847274
referring_controller    index
referring_action    index
_lm_transaction_id  0.9195199974522774
_lm_window_id   dep3508-955450102918847274
__vcon_json ["hmac","Yg2NGe+k8xotzu"]
__vcon_method   do_login
__e2e_action_id e07kmx186q
js_init {}
-------------------------------------------------
Source :
-------------------------------------------------
json=%7B%22args%22%3A%5B%5D%2C%22kwargs%22%3A%7B%22email%22%3A%22userid%40email.com%22%2C%22password%22%3A%22somePassword%22%2C%22passwordless%22%3A1%7D%7D&formkey=e50a4be87e84731aea6f9c806957d7d0&postkey=df81f33e60422d6bfbe023b35b2e5ba9&window_id=dep3508-955450102918847274&referring_controller=index&referring_action=index&_lm_transaction_id=0.9195199974522774&_lm_window_id=dep3508-955450102918847274&__vcon_json=%5B%22hmac%22%2C%22Yg2NGe%2Bk8xotzu%22%5D&__vcon_method=do_login&__e2e_action_id=e07kmx186q&js_init=%7B%7D

*

我正在使用以下代码发送请求:

  jsonData = {"args":[],"kwargs":{"email":"userid@email.com","password":"somePassword","passwordless":1}}
  requestData = { "json":str(jsonData), "formkey":"e50a4be87e84731aea6f9c806957d7d0",
                  "postkey":"401e4ee1aaa3df38f5c869ce0dfd8a58",
                  "window_id":"dep3708-2029720611434364749",
                  "referring_controller":"index",
                  "referring_action":"index",
                  "_lm_transaction_id":0.6156946511223276,
                  "_lm_window_id":"dep3708-2029720611434364749",
                  "__vcon_json":["hmac","Yg2NGe+k8xotzu"],
                  "__vcon_method":"do_login",
                  "__e2e_action_id":"e07ii5e4c3",
                  "js_init":{}
                 }
  s = requests.Session()
  r = s.request( 'POST', URL, data=requestData )

URLhttps://www.quora.com/webnode2/server_call_POST?__instart__ 但不知何故,我得到的响应是错误 400(错误请求)。这显然是因为我的请求格式不正确,我在这里做错了什么?!

4

0 回答 0