【问题标题】:get the value of anchor ( = location.hash) and send it with python POST request获取锚点的值(= location.hash)并使用 python POST 请求发送
【发布时间】:2022-01-02 09:57:57
【问题描述】:

我正在尝试使用 python 登录网页,,, 发送帖子请求时,我看到请求正文中发送了 4 个参数(使用 burp 套件):(用户名、密码、登录令牌、锚点) 我有前 3 个,但是在尝试获取“锚”的值时,我看到了:

输入 id="anchor" type="hidden" name="anchor" value="" scrpt>document.getElementById('anchor').value = location.hash;

所以它的值是 JS =location.hash 如何提取它并使用 POST 请求发送?

这里是网站:[https://elearning.yu.edu.jo/]

完整代码:

import requests
from bs4 import BeautifulSoup as bb
url = "https://84.16.252.74/login/index.php"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69'} 
s = requests.Session()
y = s.get(url, headers=headers, verify=False)
d=(s.cookies).get_dict()
soup = bb(y.text, "html.parser")
div = soup.find("input", attrs={'name': 'logintoken'})
tok=div.attrs['value']
dd = {'username': my_username, 'password': 
'my_pass',"logintoken":tok,'anchor':""}
ss = requests.post(url, data=dd,verify=False,headers=headers,cookies=d)
if "Dashboard" in ss.text:
  print('Success')

会不会是因为我将“证书验证”设置为 False?

【问题讨论】:

标签: javascript python html python-requests anchor


【解决方案1】:

对于像http://www.example.com/index.php#test 这样的网址

location.hash 将返回 #test

hash 返回 URL 中 # 符号之后的部分,包括 # 符号。

所以我认为你可以将空字符串传递给锚参数

【讨论】:

  • 我试过但很遗憾没有,是不是因为我把证书验证变成了假?
猜你喜欢
  • 2015-11-08
  • 2012-09-13
  • 2012-11-10
  • 2014-09-18
  • 1970-01-01
  • 1970-01-01
  • 2019-11-22
  • 2018-04-20
  • 2011-07-06
相关资源
最近更新 更多