-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapify-request.js
50 lines (46 loc) · 1.11 KB
/
apify-request.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require("dotenv").config()
const { ApifyClient } = require("apify-client")
// Initialize the ApifyClient with API token
const client = new ApifyClient({
token: process.env.APIFY_API_TOKEN,
})
// Prepare actor input
const input = {
handle: ["CeptorClub"],
mode: "own",
tweetsDesired: 1,
searchMode: "top",
searchTerms: [],
proxyConfig: {
useApifyProxy: true,
},
extendOutputFunction: async ({ data, item, page, request, customData }) => {
return item
},
extendScraperFunction: async ({
page,
request,
addSearch,
addProfile,
_,
addThread,
addEvent,
customData,
signal,
label,
}) => {},
customData: {},
handlePageTimeoutSecs: 500,
maxRequestRetries: 6,
maxIdleTimeoutSecs: 60,
}
;(async () => {
// Run the actor and wait for it to finish
const run = await client.actor("quacker/twitter-scraper").call(input)
// Fetch and print actor results from the run's dataset (if any)
console.log("Results from dataset")
const { items } = await client.dataset(run.defaultDatasetId).listItems()
items.forEach((item) => {
console.dir(item)
})
})()