Accessing the HTML of a page in Google

Viewed 32

I'm pretty aware of the Same Origin Policy, but the point is, what I want to access does not include JavaScript tags, Head tags or anything of that sort.

What I want to have access to, is something similar to this page. (It's not exactly this page, but a standing table for another league)

I want to use the online status of the teams for a local file and customize the table,(Including its translation to my mother language) so 'iframing' won't do the trick.

I'm pretty aware that I cannot fetch the data using the simple import methods that you use for importing data from the same domain, and it is not 'the same domain'. So I'll have security and SOP issues.

But I wondered if there's an API or method for fetching data that is not risky to fetch for the clients and Google.

Thanks in advance.

1 Answers

This kind of thing should involve server side to fetch the data. Because it is not restricted to same origin policy because it is not a browser. So you won't have CORS issue. So the challenge is just to extract the info itself.

Here's a small puppeteer script that might fetch you the first page in the series of pages and scripts to load. It won't be easy at all.

var puppeteer = require('puppeteer');

var url = 'https://www.google.com/search?q=laliga&rlz=1C1GGRV_enIR769IR769&oq=laliga&aqs=chrome.0.0i67i355j46i67j46i512j0i10i512j0i512j46i512j0i512l4.2060j1j7&sourceid=chrome&ie=UTF-8#sie=lg;/g/11sqj24s0_;2;/m/09gqx;st;fp;1;;;';
async function run() {

    var browser = await puppeteer.launch();
    var page = await browser.newPage();
    await page.goto(url);
    var result = await page.$eval("body", (element) => {
        return element.innerHTML
      })
    browser.close();

    console.log(result);
}
run();

Related