-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path03_retrieve_sync.py
More file actions
31 lines (21 loc) · 1012 Bytes
/
03_retrieve_sync.py
File metadata and controls
31 lines (21 loc) · 1012 Bytes
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
from apify_client import ApifyClient
TOKEN = 'MY-APIFY-TOKEN'
def main() -> None:
# Client initialization with the API token
apify_client = ApifyClient(token=TOKEN)
actor_client = apify_client.actor('apify/instagram-hashtag-scraper')
runs_client = actor_client.runs()
# See pagination to understand how to get more datasets
actor_datasets = runs_client.list(limit=20)
datasets_client = apify_client.datasets()
merging_dataset = datasets_client.get_or_create(name='merge-dataset')
for dataset_item in actor_datasets.items:
# Dataset items can be handled here. Dataset items can be paginated
dataset_client = apify_client.dataset(dataset_item['id'])
dataset_items = dataset_client.list_items(limit=1000)
# Items can be pushed to single dataset
merging_dataset_client = apify_client.dataset(merging_dataset['id'])
merging_dataset_client.push_items(dataset_items.items)
# ...
if __name__ == '__main__':
main()