简体   繁体   English

如何根据从Firebug工具获得的请求标头使用python中的请求模块登录到此站点?

[英]How can i login to this site with requests module in python based on the request headers i got from firebug tool?

GET /some/home.php HTTP/1.1
Host: 10.10.10.10
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://10.10.10.10/some/lverify.php
Cookie: PHPSESSID=98gngotqd668112db9e5u2emo0
Connection: keep-alive

Here is the html form 这是HTML表格

<form action="lverify.php" method="post">
<fieldset>
<legend>Log in</legend>
<label for="login">Username</label>
<input id="user" class="uname" type="text" maxlength="55" name="user">
<div class="clear"></div>
<label for="password">Password</label>
<input id="hotel_pwd" class="pwd" type="password" maxlength="25" name="pwd">
<div class="clear"></div>
<div class="clear"></div>
<br>
<input class="button" type="Submit" value="Log in" style="margin: -20px 0 0 287px;" name="Submit">
</fieldset>
</form>


#!/usr/bin/python
import requests
payload = {'user': 'abc', 'pwd': '1234'}
r = requests.post("http://10.10.10.10/some/home.php", data=payload)

i am not unable to get it working
  1. Need to the know the right systax to login to the site using requests module 需要知道正确的系统税才能使用请求模块登录到站点
  2. Is there a way i login to this site from different system and take the phpsesid and use it to login from different system without directly login from the requests 我有没有办法从其他系统登录到此站点并采用phpsesid并使用它从其他系统登录,而无需直接从请求中登录
#!/usr/bin/python
import requests

payload = { 'user': 'abc', 'pwd': '1234', 'Submit' : 'Log in' }  
r = requests.Session()  ## use this object for any POST or GET from now on ##
login = r.post("http://10.10.10.10/some/home.php", data=payload)

You should be able to log in now . 您应该现在可以登录。
If not , try with 'User-Agent' and 'Referer' in the headers 如果不是,请尝试在headers使用“ User-Agent”和“ Referer”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在使用FireBug之类的工具时从div跟踪HTML的源代码,以便可以在后端对其进行更改? - How can I trace the source of HTML from a div while using a tool such as FireBug so that I can alter it in the backend? 如何使用当前站点cookie登录到另一个站点,然后重定向到另一个页面并发出CURL请求? - How can I use current site cookies to login to another site and then redirect to another page and make a CURL request? 我如何请求带有授权标头的 Http - How can i request Http with authorization headers 如何从 python 应用程序关闭 web 站点? - How can I close a web site from a python app? 我如何使用php从客户端获取套接字的标头请求 - how can i get the headers request from client side for sockets using php 如何从PHP反向代理HTTP请求,包括选择标头 - How can I reverse proxy an HTTP request from PHP, including select headers 如何使用浏览器的代码接收(无论是否无头)获取标头请求 - How can I get headers request using codeception from browser (headless or not) 如何从我的 Wordpress 站点上的 URL 进行登录重定向? - How can I make login redirects from a URL on my Wordpress site? 如何使用PHP CURL在POST请求上设置自定义标题? - How Can I Set Custom Headers on a POST Request with PHP CURL? 如何访问$ _SERVER中未出现的请求标头? - How can I access request headers that don't appear in $_SERVER?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM