What I'm trying to do is filtering the response of a php page. for instance when I send a request to domain.com/example.php, in return I get what i asked for plus some extra content which I don't want to embed in my div. I don't need the entire content I'm only looking for a link inside a button
Here's an example:
I need to filter the whole response and only get the href inside the download button.
I created my own proxy to bypass the cross origin issue. here's the code that return the whole page inside the Div with an Id of infodown:
$('#infodown').load('https://myownproxyserver.herokuapp.com/https://tb.rg-adguard.net/dl.php?fileName=8592&lang=en-us)
I believe that it's possible to show only what I want since I got the whole thing stored in a variable any ideas?
CodePudding user response:
fetch("https://tb.rg-adguard.net/dl.php?fileName=8592&lang=en-us")
.then(res => res.text())
.then(html => {
// Same as $(html).find(".buttond > a")
const div = document.createElement("div");
div.innerHTML = html;
return div.querySelector(".buttond > a");
})
.then(console.log)
.catch(console.error);