apify / actor-scraper

House of Apify Scrapers. Generic scraping actors with a simple UI to handle complex web crawling and scraping use cases.
https://docs.apify.com/scraping
116 stars 44 forks source link

Not able to access DOM using global window/document #116

Closed imsatender closed 3 years ago

imsatender commented 3 years ago

Hi,

I am going through the documentation and on the below mentioned URL, you have written that window & document can be accessed. Now I don't want to inject jQuery as I can do all the stuff in Javascript only. But I am not able to access window/document

https://apify.com/apify/web-scraper#page-function

While document is returning object as below:

{ 2021-01-25T13:54:00.587Z location: { 2021-01-25T13:54:00.587Z ancestorOrigins: {}, 2021-01-25T13:54:00.588Z href: 'chrome-error://chromewebdata/', 2021-01-25T13:54:00.588Z origin: 'null', 2021-01-25T13:54:00.589Z protocol: 'chrome-error:', 2021-01-25T13:54:00.589Z host: 'chromewebdata', 2021-01-25T13:54:00.589Z hostname: 'chromewebdata', 2021-01-25T13:54:00.590Z port: '', 2021-01-25T13:54:00.590Z pathname: '/', 2021-01-25T13:54:00.591Z search: '', 2021-01-25T13:54:00.591Z hash: '', 2021-01-25T13:54:00.591Z assign: {}, 2021-01-25T13:54:00.592Z reload: {}, 2021-01-25T13:54:00.592Z replace: {}, 2021-01-25T13:54:00.593Z toString: {} 2021-01-25T13:54:00.593Z } 2021-01-25T13:54:00.594Z }

While I was expecting the actual DOM object. Please help me out on this.

imsatender commented 3 years ago

async function pageFunction(context) {

await context.waitFor(30000);

await context.saveSnapshot();

const pageTitle = document.querySelector('title').text;

context.log.info('TITLE: '+pageTitle);

return {

    pageTitle

};

}

My Task ID is : LpLEEMAwgfKFdoHPJ URL : https://apify.com/

mnmkng commented 3 years ago

Hi, not sure what the problem was, but I just copied your task under my account and ran it and it worked fine for both google.com and apify.com. Were you able to resolve the issue?

imsatender commented 3 years ago

Hi, not sure what the problem was, but I just copied your task under my account and ran it and it worked fine for both google.com and apify.com. Were you able to resolve the issue?

Not succeed, I am in touch with @metalwarrior665 and he has also seen that it is not working.

I am not injecting jQuery or Underscore, trying to run with Vanila JS only

mnmkng commented 3 years ago

Ok, @metalwarrior665 is our head of support. I'm sure he'll help you. Closing this issue, since it's not a problem with Web Scraper itself.