Can u share the source code running on the server


#1

the apify is great , i want to know how u execute the crawler i defined on dashboard
so can u share the source code plz !
thanks a lot !

my emai is 179000536@qq.com


#2

i do not understand your question. would you please provide more information.

This is a for profit service, not an open source project. If you want to run locally, you should use the api.


#3

Hi Barry , sorry for my question .

I do want to use apify locally , and I want to pass some variables to handleRequestFunction , like this:

handleRequestFunction: async ({

request, someData1, someData2

})

but I failed, so I want to know how you guys make it .

best regards!


#4

Hi Ethan,

since you’re mentioning the handleRequestFunction i assume that you’re using the Apify SDK and its BasicCrawler. The full docs are available at https://sdk.apify.com/docs/api/basiccrawler and you can find the source code you’re looking for on our GitHub.

With that said, you can’t just add some extra parameters to the function, because we only invoke it with the { request }. If you need access to some variables of your own in the handleRequestFunction, use the enclosing scope.


// ... some code ...

const myVar = 'Hello';

const crawler = new Apify.BasicCrawler({

    // ... other options ...

    handleRequestFunction: async ({ request }) => {
        const greeting = `${myVar} from ${request.url}`;
        console.log(greeting); // prints: Hello from https://www.example.com
    }
});

// ... run the crawler, process data ...

Is this what you were looking for?

Disclaimer: The example will not work by itself since it’s missing some important code, it’s just an example of getting access to a variable in the handleRequestFunction.


#5

thanks for your reply ,mnmkng
I will try it ~~ hope it works

best regards to u