apify 3.4.0 → 3.4.1-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +26 -0
- package/.turbo/turbo-copy.log +4 -0
- package/LICENSE.md +183 -183
- package/README.md +1 -1
- package/dist/LICENSE.md +201 -0
- package/dist/README.md +98 -0
- package/{actor.d.ts → dist/actor.d.ts} +309 -309
- package/dist/actor.d.ts.map +1 -0
- package/{actor.js → dist/actor.js} +168 -127
- package/dist/actor.js.map +1 -0
- package/{charging.d.ts → dist/charging.d.ts} +18 -18
- package/dist/charging.d.ts.map +1 -0
- package/{charging.js → dist/charging.js} +26 -14
- package/dist/charging.js.map +1 -0
- package/{configuration.d.ts → dist/configuration.d.ts} +4 -4
- package/dist/configuration.d.ts.map +1 -0
- package/{configuration.js → dist/configuration.js} +14 -3
- package/dist/configuration.js.map +1 -0
- package/{index.d.ts → dist/index.d.ts} +6 -6
- package/dist/index.d.ts.map +1 -0
- package/{index.js → dist/index.js} +6 -6
- package/dist/index.js.map +1 -0
- package/dist/key_value_store.d.ts.map +1 -0
- package/{key_value_store.js → dist/key_value_store.js} +1 -1
- package/dist/key_value_store.js.map +1 -0
- package/dist/package.json +80 -0
- package/{platform_event_manager.d.ts → dist/platform_event_manager.d.ts} +4 -4
- package/{platform_event_manager.d.ts.map → dist/platform_event_manager.d.ts.map} +1 -1
- package/{platform_event_manager.js → dist/platform_event_manager.js} +13 -10
- package/dist/platform_event_manager.js.map +1 -0
- package/{proxy_configuration.d.ts → dist/proxy_configuration.d.ts} +10 -10
- package/dist/proxy_configuration.d.ts.map +1 -0
- package/{proxy_configuration.js → dist/proxy_configuration.js} +52 -40
- package/dist/proxy_configuration.js.map +1 -0
- package/dist/utils.d.ts.map +1 -0
- package/{utils.js → dist/utils.js} +5 -6
- package/dist/utils.js.map +1 -0
- package/package.json +10 -10
- package/actor.d.ts.map +0 -1
- package/actor.js.map +0 -1
- package/charging.d.ts.map +0 -1
- package/charging.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/key_value_store.d.ts.map +0 -1
- package/key_value_store.js.map +0 -1
- package/platform_event_manager.js.map +0 -1
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
- package/utils.d.ts.map +0 -1
- package/utils.js.map +0 -1
- /package/{index.mjs → dist/index.mjs} +0 -0
- /package/{key_value_store.d.ts → dist/key_value_store.d.ts} +0 -0
- /package/{utils.d.ts → dist/utils.d.ts} +0 -0
package/dist/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Apify SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/apify)
|
|
4
|
+
[](https://www.npmjs.com/package/apify)
|
|
5
|
+
[](https://discord.gg/jyEM2PRvMU)
|
|
6
|
+
[](https://github.com/apify/apify-sdk-js/actions/workflows/test-and-release.yaml)
|
|
7
|
+
|
|
8
|
+
Apify SDK provides the tools required to run your own Apify Actors. The crawlers and scraping related tools, previously included in Apify SDK (v2), have been split into a brand-new module - [`crawlee`](https://npmjs.org/crawlee), while keeping the Apify specific parts in this module.
|
|
9
|
+
|
|
10
|
+
> Would you like to work with us on Crawlee, Apify SDK or similar projects? We are hiring [Node.js engineers](https://apify.com/jobs#senior-node.js-engineer).
|
|
11
|
+
|
|
12
|
+
## Upgrading from v2
|
|
13
|
+
|
|
14
|
+
A lot of things have changed since version 2 of the Apify SDK, including the split of the crawlers to the new [`crawlee`](https://npmjs.org/crawlee) module. We've written a guide to help you easily migrate from v2 to v3. Visit the [Upgrading Guide](https://docs.apify.com/sdk/js/docs/upgrading/upgrading-to-v3) to find out what changes you need to make (especially the section related to this very [Apify SDK](https://docs.apify.com/sdk/js/docs/upgrading/upgrading-to-v3#apify-sdk)), and, if you encounter any issues, join our [Discord server](https://discord.gg/jyEM2PRvMU) for help!
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
This short tutorial will set you up to start using Apify SDK in a minute or two.
|
|
19
|
+
If you want to learn more, proceed to the [Apify Platform](https://docs.apify.com/sdk/js/docs/guides/apify-platform)
|
|
20
|
+
guide that will take you step by step through running your Actor on Apify's platform.
|
|
21
|
+
|
|
22
|
+
Apify SDK requires [Node.js](https://nodejs.org/en/) 16 or later. Add Apify SDK to any Node.js project by running:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install apify crawlee playwright
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> For this example, we'll also install the [`crawlee`](https://npmjs.org/crawlee) module, as it now provides the crawlers that were previously exported by Apify SDK. If you don't plan to use crawlers in your Actors, then you don't need to install it. Keep in mind that neither `playwright` nor `puppeteer` are bundled with `crawlee` in order to reduce install size and allow greater flexibility. That's why we manually install it with NPM. You can choose one, both, or neither.
|
|
29
|
+
|
|
30
|
+
There are two ways to initialize your Actor: by using the `Actor.main()` function you're probably used to, or by calling `Actor.init()` and `Actor.exit()` manually. We prefer explicitly calling `init` and `exit`.
|
|
31
|
+
|
|
32
|
+
### Using `Actor.init()` and `Actor.exit()`
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { Actor } from 'apify';
|
|
36
|
+
import { PlaywrightCrawler } from 'crawlee';
|
|
37
|
+
|
|
38
|
+
await Actor.init();
|
|
39
|
+
|
|
40
|
+
const crawler = new PlaywrightCrawler({
|
|
41
|
+
async requestHandler({ request, page, enqueueLinks }) {
|
|
42
|
+
// Extract HTML title of the page.
|
|
43
|
+
const title = await page.title();
|
|
44
|
+
console.log(`Title of ${request.url}: ${title}`);
|
|
45
|
+
|
|
46
|
+
// Add URLs that point to the same hostname.
|
|
47
|
+
await enqueueLinks();
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await crawler.run(['https://crawlee.dev/']);
|
|
52
|
+
|
|
53
|
+
await Actor.exit();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Using `Actor.main()`
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { Actor } from 'apify';
|
|
60
|
+
import { PlaywrightCrawler } from 'crawlee';
|
|
61
|
+
|
|
62
|
+
await Actor.main(async () => {
|
|
63
|
+
const crawler = new PlaywrightCrawler({
|
|
64
|
+
async requestHandler({ request, page, enqueueLinks }) {
|
|
65
|
+
// Extract HTML title of the page.
|
|
66
|
+
const title = await page.title();
|
|
67
|
+
console.log(`Title of ${request.url}: ${title}`);
|
|
68
|
+
|
|
69
|
+
// Add URLs that point to the same hostname.
|
|
70
|
+
await enqueueLinks();
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
await crawler.run(['https://crawlee.dev/']);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Support
|
|
79
|
+
|
|
80
|
+
If you find any bug or issue with the Apify SDK, please [submit an issue on GitHub](https://github.com/apify/apify-sdk-js/issues).
|
|
81
|
+
For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify) or contact support@apify.com
|
|
82
|
+
|
|
83
|
+
## Contributing
|
|
84
|
+
|
|
85
|
+
Your code contributions are welcome, and you'll be praised to eternity!
|
|
86
|
+
If you have any ideas for improvements, either submit an issue or create a pull request.
|
|
87
|
+
For contribution guidelines and the code of conduct,
|
|
88
|
+
see [CONTRIBUTING.md](https://github.com/apify/apify-sdk-js/blob/master/CONTRIBUTING.md).
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
This project is licensed under the Apache License 2.0 -
|
|
93
|
+
see the [LICENSE.md](https://github.com/apify/apify-sdk-js/blob/master/LICENSE.md) file for details.
|
|
94
|
+
|
|
95
|
+
## Acknowledgments
|
|
96
|
+
|
|
97
|
+
Many thanks to [Chema Balsas](https://www.npmjs.com/~jbalsas) for giving up the `apify` package name
|
|
98
|
+
on NPM and renaming his project to [jsdocify](https://www.npmjs.com/package/jsdocify).
|