I was wondering if there was a better way to capture a value inside an input tag rather than using regex in JS.
"<html><head></head><body onload=\"document.form1.submit()\"><form name=\"form1\" method=\"post\" action=\"\" ><input name=\"Token\" type=\"hidden\" value=\"\"><input name=\"ID\" type=\"hidden\" value=\"12120012732dafd4\"></form></body></html>"
Ideally I would like to capture just the ID value 12120012732dafd4
Since there is no DOM in node you have to initialize a cheerio instance from an HTML string. (this example comes from the cheerio readme)
var cheerio = require('cheerio'),
$ = cheerio.load("<html><head></head><body onload=\"document.form1.submit()\"><form name=\"form1\" method=\"post\" action=\"\" ><input name=\"Token\" type=\"hidden\" value=\"\"><input name=\"ID\" type=\"hidden\" value=\"12120012732dafd4\"></form></body></html>"
);
$('input').val();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With