Skip to content

Commit 3fb245b

Browse files
committed
add enrichments example
1 parent e985414 commit 3fb245b

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

examples/Enrichments.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Using Enrichments With Server-side JavaScript
2+
3+
Using enrichments with [Outscraper API](https://app.outscraper.com/api-docs).
4+
5+
## Installation
6+
7+
Install the package with:
8+
```bash
9+
npm install outscraper --save
10+
# Or
11+
yarn add outscraper
12+
```
13+
14+
[Link to the NPM package page](https://www.npmjs.com/package/outscraper)
15+
16+
## Initialization
17+
```js
18+
const Outscraper = require('outscraper');
19+
// Or using ES modules:
20+
import Outscraper from 'outscraper';
21+
22+
let client = new Outscraper('SECRET_API_KEY');
23+
24+
```
25+
[Link to the profile page to create the API key](https://app.outscraper.com/profile)
26+
27+
## Usage
28+
29+
```js
30+
# Enriching data from Google Maps with Emails & Contacts Scraper and validating emails:
31+
client.googleMapsSearch(
32+
["bars ny usa"],
33+
limit=10, // limit of palces per each query
34+
language='en',
35+
region='US',
36+
skip=0,
37+
dropDuplicates=false,
38+
enrichment=['domains_service', 'emails_validator_service']
39+
).then(response => {
40+
response.forEach(queryPlaces => {
41+
queryPlaces.forEach(place => {
42+
console.log('name: ', place);
43+
});
44+
});
45+
});
46+
```

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ class Outscraper {
5757
return response['data'];
5858
}
5959

60-
async googleMapsSearch(query, limit = 20, language = 'en', region = null, skip = 0, dropDuplicates = false) {
60+
async googleMapsSearch(query, limit = 20, language = 'en', region = null, skip = 0, dropDuplicates = false, enrichment = null) {
6161
const response = await this.getAPIRequest('/maps/search-v2', {
6262
query: toArray(query),
6363
language,
6464
region,
6565
organizationsPerQueryLimit: limit,
6666
skipPlaces: skip,
6767
dropDuplicates,
68+
enrichment: enrichment ? toArray(enrichment) : null,
6869
async: false,
6970
});
7071
return response['data'];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "outscraper",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "The library provides convenient access to the Outscraper API. Allows using Outscraper's services from your code. See https://outscraper.com for details.",
55
"main": "index.js",
66
"scripts": {

test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Outscraper = require('./index');
22
// import Outscraper from 'outscraper';
33

4-
let client = new Outscraper('YXV0aDB8NjAyMDFmODYwOTQ5M2UwMDZhOGM4YjZhfDhkMjQ2NDQ1Nzc');
4+
let client = new Outscraper('YXV0aDB8NjAyMDFmODYwOTQ5M2UwMDZhOGM4YjZhfDg3ZmE1Mjc0ZTk');
55

66
// Scrap Places by Two Queries
77
// client.googleMapsSearch(['restaurants brooklyn usa'], limit=20, language='en', region='us'
@@ -11,14 +11,20 @@ let client = new Outscraper('YXV0aDB8NjAyMDFmODYwOTQ5M2UwMDZhOGM4YjZhfDhkMjQ2NDQ
1111
// });
1212

1313
client.googleMapsSearch(
14-
["ChIJ8ccnM7dbwokRy-pTMsdgvS4", "ChIJN5X_gWdZwokRck9rk2guJ1M", "ChIJxWLy8DlawokR1jvfXUPSTUE"],
15-
limit=1, // limit of palces per each query
14+
["bars ny usa"],
15+
limit=10, // limit of palces per each query
16+
language='en',
17+
region='US',
18+
skip=0,
19+
dropDuplicates=false,
20+
enrichment=['domains_service', 'emails_validator_service']
1621
).then(response => {
1722
response.forEach(queryPlaces => {
1823
queryPlaces.forEach(place => {
1924
console.log('--------------------');
2025
console.log('name: ', place.name);
2126
console.log('place_id: ', place.place_id);
27+
console.log('name: ', place);
2228
});
2329
});
2430
});

0 commit comments

Comments
 (0)