i have solution want grab some content from url.
I have code in server.js:
let request = require('request');
let cheerio = require('cheerio');
let url = "domain[dot]com/title-to-video";
request(url, function(error, response, html){
if (!error && response.statusCode == 200) {
let $ = cheerio.load(html);
console.log($.text());
} else {
console("We've encountered an error: " + error);
}
});
It return html:
<html>
<head>
<title>Website Title</title>
</head>
<body>
...
<script>
getplayer.setvd1('http://abc[dot]com/video34345453.mp4');
getplayer.setvd2('http://abc[dot]com/video43243234.mp4');
</script>
...
</body>
</html>
I want output as:
{
http://abc[dot]com/video34345453.mp4,
http://abc[dot]com/video43243234.mp4
}
UPDATE: after found on internet, i am try ti fix:
const strvd1 = $('script:not([src])')[0].children[0].data;
const resultvd1 = strvd1.match(/setvd1\('(https:.+?)'\);/)[1];
output: http://abc[dot]com/video34345453.mp4
const strvd2 = $('script:not([src])')[0].children[0].data;
const resultvd2 = strvd2.match(/setvd2\('(https:.+?)'\);/)[1];
output: http://abc[dot]com/video43243234.mp4
thankyou any solution.
In your if statement, try something like: