我有一个网址,我需要从html检索一些数据,以进一步工作。
var request = require('request');
request('http://10.9.1.252:8111/goip/en/dosend.php?USERNAME=root&PASSWORD=root&smsprovider=2&smsnum=0036301234567&method=2&Memo=Test', function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});
使用下面的代码,我得到了以下输出:
error: null
statusCode: 200
body: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="style.css" rel="stylesheet" type="text/css">
<title>Sending Messge</title>
</head>
<body>
<br>total will send: 1 <br><script language='javascript'>window.location = 'resend.php?messageid=85&USERNAME=root&PASSWORD=root'</script>
如何从html中检索messageid?有人能帮我一下吗?
提前感谢
发布于 2018-06-04 02:33:01
要做到这一点,最快、最糟糕的方法就是使用regular expression
const regex = /messageid=(\d+)/g
const messageId = regex.exec(body)[1]
https://stackoverflow.com/questions/50669571
复制相似问题