我的头撞到墙上了…有谁能帮我把脑筋集中在申请一份工作上吗?在
我试图在一个网站上工作,但首先我必须通过登录。。。我一直在谷歌上搜索,但到目前为止我还没弄清楚。我对网络很在行,但在玛雅的python方面有一些经验。在
这是我到目前为止的情况
import requests
login_url = 'https://example.com/examplelogin
login_payload = {'j_username':'myusername', 'j_password':'mypassword'}
with requests.Session() as s:
r = s.post(login_url, data = login_payload)
这是我要填写的表格:
^{pr2}$对于r.status_code
我得到200
,但是r.text
只是登录页面HTML。。。它不能让我登录并让我通过。。。在
我错过了什么?在
如果站点没有某种API,则可能无法使用请求库来访问它。你应该看看Selenium它允许你使用FireFox访问页面。如果你想要一个没有头的版本,通常要快得多,你可以使用phantomjs。在
您希望将请求发送到/idp/Authn/UserPassword而不是/examplelogin。如果表单有action属性,浏览器将把POST发送到该属性中指定的地址。在
但是,如果您想使用site,那么最好按照@emett speer的建议使用Selenium,因为您可能不想手动与站点对话(如果URL将被更改,会怎么样等等)。在
请求是一个HTTP库。在使用它之前,你必须阅读关于HTTP的内容。在
事实上,你的表单应该和POST请求一样。你还得读一读forms。在
我认为完成一个教程来了解它是如何工作的是一个好主意。There is a good place to start.
相关问题 更多 >
编程相关推荐