如何从功能标签的页面源代码中获取值? [英] How to get a value from page source code from a function tag?

查看:81
本文介绍了如何从功能标签的页面源代码中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是源代码中的功能

function dosubmit()
  {
    if (getObj("Frm_Username").value == "")
    {
      getObj("errmsg").innerHTML = "Username cannot be empty.";
      getObj("myLayer").style.visibility = "visible" ;
      return;
    }
    else
    {
      getObj("LoginId").disabled = true;
      getObj("Frm_Logintoken").value = "3";
      document.fLogin.submit();
    }
  }

我想获取getObj("Frm_Logintoken")的值,因为我无法提取该值 来自#Frm_Logintoken

i want to get the value of getObj("Frm_Logintoken") as i can't pull the value from #Frm_Logintoken

使用document.getElementById("#Frm_Logintoken")这使我为空

因为Frm_Logintoken仅在我单击提交"时才得到它的值.

because Frm_Logintoken only gets it's value when i click submit .

<input type="hidden" name="Frm_Logintoken" id="Frm_Logintoken" value="">

完整的页面代码

我在网上找到了这个/getObj\("Frm_Logintoken"\).value = "(.*)";/g,但是当我运行它时...它又给了我相同的提示!它是完整代码

i found this online /getObj\("Frm_Logintoken"\).value = "(.*)";/g but when i run it ... it gives me the same line again ! it's full code

我找到了另一个正则表达式,但甚至不知道如何使用它

another regular expression i found but don't even know how to use it

要搜索的正则表达式示例: before_egrep =' N1 :getObj("Frm_Logintoken").value =(\ w +)"'

Example of a regular expression to search: before_egrep='N1:getObj("Frm_Logintoken").value = "(\w+)"'

此处, N1 被分配了反向引用的值- 用括号表示. \ w +表示主要的复合字符, 这是"[_ [:alnum:]]"的同义词.再次-注意 括号-这是反向链接.同时,也有 源代码片段中的括号-需要将其转义

Here, N1 is assigned the value of the back reference - the expression in parentheses. \w + denotes the main compound characters, this is a synonym for "[_[:alnum:]]". Once again - pay attention to the brackets - this is the back link. At the same time, there are also parentheses in the source code fragment - they need to be escaped

我正在尝试制作一个可以在后台运行的自动登录脚本

i am trying to make an auto login script that works in the background like it

不向用户显示登录表单页面,而是仅显示其后的页面

doesn't show the user the login form page but the only the page after it

而且我也在网上找到了此代码,但不知道这是怎么回事 它包含xhr .

and i have found this code online too but don't know what's about it contains xhr .

吸引我注意的那一行是

/getObj\("Frm_Logintoken"\).value = "(.*)";/g 

当我运行它时...又给了我一行!

when i run it ... it gives me the line again !

一些注意事项:

我尝试了document.getElementById("Frm_Logintoken").value,但是它给了我空的",因为

i have tried document.getElementById("Frm_Logintoken").value but it gives me empty "" because

Frm_Logintoken仅在单击提交时得到它的值.

Frm_Logintoken only gets it's value when i click submit .

如果Frm_Logintoken令牌值不同于页面中的一个,则该页面甚至不会接受正确的密码.

the page will not even accept the correct password if the Frm_Logintoken token value isn't the same as one in the page.

Frm_Logintoken是由页面生成的令牌,每次成功登录后基本上都会增加一个.

the Frm_Logintoken is a token generated by the page and it basically increment by one on each successful login.

推荐答案

要获取您的价值,您可以使用捕获组([^"]+)和否定的字符类:

To get your value you might use a capturing group ([^"]+) and a negated character class:

\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)";

正则表达式演示 | JavaScript演示

例如:

let str = `getObj("Frm_Logintoken").value = "3";`;
let pattern =/\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)";/;

console.log(str.match(pattern)[1]); //3

这篇关于如何从功能标签的页面源代码中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆