Home > Mobile >  Get data from opened html tab
Get data from opened html tab

Time:01-29

My point is to get some data from a html page (text and tables). However, when I am using the different functions in Google Sheets (importxml; importhtml); those ones are not working ("Could not fetch the URL"). I tried many alternative methods using google sheets by none are working due to website type (I guess).

In this way, as alternative option, I want to know if there is a specific code line(s) in Google Apps Script to copy values from open web page (opened in a Google Chrome tab) in order to paste those values in Google Sheets tab (opened in another tab of Google Chrome). I think this method will avoid to open the website & consequently the same error as import functions in Google Sheets.


As additional comments the UrlFetch is not permitted by my admin

CodePudding user response:

As your admin doesn't allow the use of UrlFetch it's not possible because Google Apps Script is not able access the opened tabs of your web browser.

Reference

https://developers.google.com/apps-script/

CodePudding user response:

Apps Script is just javascript so you could use a web data API like https://rapidapi.com/fusioncow11/api/web-data1 and you could implement it with something like:

const options = {
    method: 'GET',
    headers: {
        data: 'https://www.google.com/',
        style: 'html',
        'X-RapidAPI-Key': 'keyhere',
        'X-RapidAPI-Host': 'web-data1.p.rapidapi.com'
    }
};

fetch('https://web-data1.p.rapidapi.com/', options)
    .then(response => response.json())
    .then(response => console.log(response))
    .catch(err => console.error(err));
  • Related