Reputation: 21
I'm trying to perform web scrapping through web scrapping API's. For using the API, it's mandatory to some extent to use axios. Now I'm unable to find a way to use axios with web editor.
I tried the given method and the code always returns null.
const query = 'site:linkedin.com/company "' + 'Company Name' + '"';
const options = {
token: "223E9D905C2BC87EBD5181677A8C240A",
url: 'https://www.google.com/search?q=' + encodeURIComponent(query)
};
axios.get("https://scraperbox.com/api/scrape", options)
.then(response => {
Logger.log(response.data)
}).catch(error => {
Logger.log(error.response.data.errors || error)
});
Upvotes: 2
Views: 2740
Reputation: 5332
I also tried to bypass UrlFetchApp.fetch
with axios
. I changed your code to:
async function fetchtest(refresh) {
const url = `https://randomuser.me/api/`
await axios.get(url)
.then(response => {
Logger.log(response)
}).catch(error => {
Logger.log(error)
});
}
And it works but I got error:
There is no suitable adapter to dispatch the request since :
- adapter xhr is not supported by the environment
- adapter http is not available in the build
So XMLHttpRequest
is unavailable, fetch
also unavailable. http
from Node also unavailable.
There is nothing else available from ES6, so we forced to use UrlFetchApp.fetch
.
Upvotes: 0