Jquery 选择器 - 在 html javascript 代码中记录特定文本字段
Jquery selector - logging a specific text field within a html javascript code
我正在使用 Node js、myhttp 和 Cheerio 从网页中提取一些数据。
我在提取出现在 html 下的特定文本 'var key = xxxxxx' 时遇到困难
脚本 -> 函数
尝试过
var _key = $("script:contains('var key')");
console.log('var key ' + _key);
完整内容已记录。
当我尝试时
var _key = $("script:nth-child(5)", this).text().trim();
console.log('var key ' + _key);
没有任何记录。
有没有办法单独获取密钥(下面示例代码中的值 d1f0573f-2413-46f4-946d-bdd6d9)作为变量存储在我的代码中var_key?
类似地,任何获取下一行“document.hiddenform.action”的完整url的方法
感谢任何帮助。一直在查看各种论坛,但没有找到任何有用的东西。
谢谢
样本Html文件
<html>
<head>
<title>
</title>
<script language='javascript' src='../JS/Abc.js' type="text/javascript"></script>
<script language='javascript' src='../JS/de.js' type="text/javascript"></script>
<script language="javascript" type="text/JavaScript">
<!--
function abc(){
var v_temp = "../abcDispPage.jsp";
AjaxFun.sendRequest("GET",v_temp,funDisply);
}
function Validate()
{
if(document.login.requLog.value=="")
{
alert("Please enter valid User id");
document.login.requLog.focus();
}
else
{
var key = 'd1f0573f-2413-46f4-946d-bdd6d9';
document.hiddenform.action = "../ShowImage.jsp?43a091d4-6290-4f9f-8c8e-3ac1630adca2="
document.hiddenform.submit();
}
}
</script>
</head>
<body onload="javascript:check2fa();func_get_reig();">
<form name="hiddenform" method='post'>
<input type="hidden" name="requLog" value=""/>
</form>
//html code for page
</body>
</html>
为此你需要正则表达式:
let key = $.html().match(/var key = '(.*)'/)[1]
我正在使用 Node js、myhttp 和 Cheerio 从网页中提取一些数据。
我在提取出现在 html 下的特定文本 'var key = xxxxxx' 时遇到困难 脚本 -> 函数
尝试过
var _key = $("script:contains('var key')");
console.log('var key ' + _key);
完整内容已记录。
当我尝试时
var _key = $("script:nth-child(5)", this).text().trim();
console.log('var key ' + _key);
没有任何记录。
有没有办法单独获取密钥(下面示例代码中的值 d1f0573f-2413-46f4-946d-bdd6d9)作为变量存储在我的代码中var_key?
类似地,任何获取下一行“document.hiddenform.action”的完整url的方法
感谢任何帮助。一直在查看各种论坛,但没有找到任何有用的东西。
谢谢
样本Html文件
<html>
<head>
<title>
</title>
<script language='javascript' src='../JS/Abc.js' type="text/javascript"></script>
<script language='javascript' src='../JS/de.js' type="text/javascript"></script>
<script language="javascript" type="text/JavaScript">
<!--
function abc(){
var v_temp = "../abcDispPage.jsp";
AjaxFun.sendRequest("GET",v_temp,funDisply);
}
function Validate()
{
if(document.login.requLog.value=="")
{
alert("Please enter valid User id");
document.login.requLog.focus();
}
else
{
var key = 'd1f0573f-2413-46f4-946d-bdd6d9';
document.hiddenform.action = "../ShowImage.jsp?43a091d4-6290-4f9f-8c8e-3ac1630adca2="
document.hiddenform.submit();
}
}
</script>
</head>
<body onload="javascript:check2fa();func_get_reig();">
<form name="hiddenform" method='post'>
<input type="hidden" name="requLog" value=""/>
</form>
//html code for page
</body>
</html>
为此你需要正则表达式:
let key = $.html().match(/var key = '(.*)'/)[1]