I'm using the Fetch API to get some (public) data from a webpage. Here is my code:
const proxyurl = "https://cors-anywhere.herokuapp.com/";
var bookUrl = "the+old+man+and+the+sea";
var url = 'https://miss.ent.sirsidynix.net/client/en_US/mlsathome/search/results?qu=' +
bookUrl + '&te=ILS';
fetch(proxyurl + url).then(function(result){
return result.text();
}).then(function(text){
var parser = new DOMParser();
var html = parser.parseFromString(text, 'text/html');
var divs = html.getElementsByTagName('div');
var x = html.getElementsByTagName('thead');
console.log(divs);
console.log(x);
});
The output in the console for divs is "HTMLCollection(80)" so I know the page has loaded, but the output for x is "HTMLCollection(0)" meaning that it found no thead elements. However, when I look at the source code for the page, I can see multiple thead tags. whenever I load the page, the tables do take a little longer to load. How do I get the Fetch API to get the entire page?
theadelements in the html until javascript on that page runs and puts them thereI still can't access the tables the website has generatedof course not, because you are getting the HTML, as I said. What you get using fetch is the raw page, the javascript in that page does not run, therefore no tables