outscraper 0.3.6 → 0.3.7
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.
- checksums.yaml +4 -4
- data/examples/Businesses.md +85 -0
- data/lib/outscraper/version.rb +1 -1
- data/lib/outscraper.rb +83 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97c677370f1667c0a830e12a858fc1aa0a830182c145830205151cbf2a0719a3
|
|
4
|
+
data.tar.gz: 541a28805f574e7ad9d57df8a7d90bb43ee7b03128cc3ca33c45e5d7f0c93a76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f67f131e3546b2628c35679312655d725fb18f9fa905d41030ca7744269b9508dc0f6dcba83d0ab30355ad43b4f7858a9b9209f08cbeada6ac7047bca57a8a32
|
|
7
|
+
data.tar.gz: 5d3d36c762fd24e04266b0bb4249ae9b3183de35bd27a77c39be630ccc2af243d4055d2bdac60a69814f80b7eca812d5be1d51af59a17d646805f517a767ae7a
|
data/examples/Businesses.md
CHANGED
|
@@ -95,6 +95,91 @@ When both structured params and `query` are provided:
|
|
|
95
95
|
- for `limit`, `cursor`, and `include_total`, plain-text values take priority when present
|
|
96
96
|
- if a value is not specified, API defaults are used
|
|
97
97
|
|
|
98
|
+
### Search businesses with enrichments
|
|
99
|
+
|
|
100
|
+
`enrichments` can be provided in three formats:
|
|
101
|
+
|
|
102
|
+
- **Hash (recommended)** — send a structured object with options per enrichment
|
|
103
|
+
- **Array** — enable enrichments without options
|
|
104
|
+
- **String** — enable a single enrichment without options
|
|
105
|
+
|
|
106
|
+
#### Enrichments as Hash (recommended)
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
results = client.businessesSearch(
|
|
110
|
+
filters: {
|
|
111
|
+
country_code: "US",
|
|
112
|
+
states: ["CA", "NY"],
|
|
113
|
+
types: ["restaurant", "cafe"]
|
|
114
|
+
},
|
|
115
|
+
limit: 10,
|
|
116
|
+
fields: ["name", "phone", "website", "rating", "reviews"],
|
|
117
|
+
enrichments: {
|
|
118
|
+
"contacts_n_leads" => {
|
|
119
|
+
"contacts_per_company" => 4,
|
|
120
|
+
"emails_per_contact" => 2
|
|
121
|
+
},
|
|
122
|
+
"company_insights" => {}
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
puts results
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Enrichments as Array
|
|
130
|
+
|
|
131
|
+
```ruby
|
|
132
|
+
results = client.businessesSearch(
|
|
133
|
+
filters: { country_code: "US", states: ["NY"] },
|
|
134
|
+
limit: 10,
|
|
135
|
+
enrichments: ["contacts_n_leads", "company_insights"]
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
puts results
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Enrichments as String
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
results = client.businessesSearch(
|
|
145
|
+
filters: { country_code: "US", states: ["NY"] },
|
|
146
|
+
limit: 10,
|
|
147
|
+
enrichments: "contacts_n_leads"
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
puts results
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Full JSON-style parameters example
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
params = {
|
|
157
|
+
filters: {
|
|
158
|
+
country_code: "US",
|
|
159
|
+
states: ["CA", "NY"],
|
|
160
|
+
types: ["restaurant", "cafe"]
|
|
161
|
+
},
|
|
162
|
+
limit: 900,
|
|
163
|
+
cursor: nil,
|
|
164
|
+
include_total: false,
|
|
165
|
+
fields: [
|
|
166
|
+
"name", "types", "address", "country", "website",
|
|
167
|
+
"phone", "rating", "reviews"
|
|
168
|
+
],
|
|
169
|
+
enrichments: {
|
|
170
|
+
"contacts_n_leads" => {
|
|
171
|
+
"contacts_per_company" => 4,
|
|
172
|
+
"emails_per_contact" => 2
|
|
173
|
+
},
|
|
174
|
+
"company_insights" => {}
|
|
175
|
+
},
|
|
176
|
+
query: "Find hotels in California and Illinois with rating 4.2+ and status operational. Return fields: name, address, rating and reviews. Limit results to 6. Enrich data with contacts_n_leads. Contact per company set to 8"
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
results = client.businessesSearch(**params)
|
|
180
|
+
puts results
|
|
181
|
+
```
|
|
182
|
+
|
|
98
183
|
### Iterate through all results (auto-pagination)
|
|
99
184
|
|
|
100
185
|
```ruby
|
data/lib/outscraper/version.rb
CHANGED
data/lib/outscraper.rb
CHANGED
|
@@ -378,7 +378,7 @@ module Outscraper
|
|
|
378
378
|
async: async_request
|
|
379
379
|
}).parsed_response['data']
|
|
380
380
|
end
|
|
381
|
-
|
|
381
|
+
|
|
382
382
|
def yellowpages_search(query, location: 'New York, NY', limit: 100, region: nil, enrichment: [], fields: '', async_request: false, ui: nil, webhook: nil)
|
|
383
383
|
enrichment_array = enrichment.is_a?(Array) ? enrichment : [enrichment]
|
|
384
384
|
response = self.class.get('/yellowpages-search', query: {
|
|
@@ -412,27 +412,92 @@ module Outscraper
|
|
|
412
412
|
include_total: false,
|
|
413
413
|
cursor: nil,
|
|
414
414
|
fields: nil,
|
|
415
|
+
enrichments: nil,
|
|
416
|
+
contacts_per_company: nil,
|
|
417
|
+
emails_per_contact: nil,
|
|
415
418
|
async_request: false,
|
|
416
419
|
ui: false,
|
|
417
420
|
webhook: nil,
|
|
418
421
|
query: nil
|
|
419
422
|
)
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
423
|
+
if contacts_per_company && contacts_per_company < 1
|
|
424
|
+
raise ArgumentError, 'contacts_per_company must be >= 1'
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
if emails_per_contact && emails_per_contact < 1
|
|
428
|
+
raise ArgumentError, 'emails_per_contact must be >= 1'
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
enrichments_normalized = nil
|
|
432
|
+
|
|
433
|
+
if enrichments.is_a?(Hash)
|
|
434
|
+
enrichments_normalized = enrichments
|
|
435
|
+
elsif enrichments.is_a?(Array)
|
|
436
|
+
enrichments_normalized = enrichments
|
|
437
|
+
elsif enrichments.is_a?(String) || enrichments.is_a?(Symbol)
|
|
438
|
+
enrichments_normalized = enrichments.to_s
|
|
439
|
+
elsif !enrichments.nil?
|
|
440
|
+
enrichments_normalized = Array(enrichments)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
if !contacts_per_company.nil? || !emails_per_contact.nil?
|
|
444
|
+
cpp = contacts_per_company || 3
|
|
445
|
+
epc = emails_per_contact || 1
|
|
446
|
+
|
|
447
|
+
case enrichments_normalized
|
|
448
|
+
when nil
|
|
449
|
+
enrichments_normalized = { 'contacts_n_leads' => { 'contacts_per_company' => cpp, 'emails_per_contact' => epc } }
|
|
450
|
+
when Hash
|
|
451
|
+
enrichments_normalized['contacts_n_leads'] ||= {}
|
|
452
|
+
enrichments_normalized['contacts_n_leads']['contacts_per_company'] = cpp
|
|
453
|
+
enrichments_normalized['contacts_n_leads']['emails_per_contact'] = epc
|
|
454
|
+
when Array
|
|
455
|
+
unless enrichments_normalized.map(&:to_s).include?('contacts_n_leads')
|
|
456
|
+
raise ArgumentError, 'contacts_per_company and emails_per_contact require enrichments to include "contacts_n_leads"'
|
|
457
|
+
end
|
|
458
|
+
# Expand array to object so we can include options
|
|
459
|
+
expanded = {}
|
|
460
|
+
enrichments_normalized.each { |name| expanded[name.to_s] = {} }
|
|
461
|
+
expanded['contacts_n_leads']['contacts_per_company'] = cpp
|
|
462
|
+
expanded['contacts_n_leads']['emails_per_contact'] = epc
|
|
463
|
+
enrichments_normalized = expanded
|
|
464
|
+
when String
|
|
465
|
+
unless enrichments_normalized == 'contacts_n_leads'
|
|
466
|
+
raise ArgumentError, 'contacts_per_company and emails_per_contact require enrichments to include "contacts_n_leads"'
|
|
467
|
+
end
|
|
468
|
+
enrichments_normalized = { 'contacts_n_leads' => { 'contacts_per_company' => cpp, 'emails_per_contact' => epc } }
|
|
469
|
+
else
|
|
470
|
+
raise ArgumentError, 'Invalid enrichments type'
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
payload = {
|
|
475
|
+
filters: (filters || {}),
|
|
476
|
+
limit: limit,
|
|
477
|
+
include_total: include_total,
|
|
478
|
+
cursor: cursor,
|
|
479
|
+
fields: fields ? Array(fields) : nil,
|
|
480
|
+
enrichments: enrichments_normalized,
|
|
481
|
+
query: query,
|
|
482
|
+
async: async_request,
|
|
483
|
+
ui: ui,
|
|
484
|
+
webhook: webhook
|
|
485
|
+
}.compact
|
|
486
|
+
|
|
487
|
+
postAPIRequest('/businesses', payload)
|
|
431
488
|
|
|
432
|
-
postAPIRequest('/businesses', payload)
|
|
433
489
|
end
|
|
434
490
|
|
|
435
|
-
def businessesIterSearch(
|
|
491
|
+
def businessesIterSearch(
|
|
492
|
+
filters: {},
|
|
493
|
+
limit: 10,
|
|
494
|
+
fields: nil,
|
|
495
|
+
include_total: false,
|
|
496
|
+
enrichments: nil,
|
|
497
|
+
contacts_per_company: nil,
|
|
498
|
+
emails_per_contact: nil,
|
|
499
|
+
query: nil
|
|
500
|
+
)
|
|
436
501
|
cursor = nil
|
|
437
502
|
all_items = []
|
|
438
503
|
|
|
@@ -443,6 +508,10 @@ module Outscraper
|
|
|
443
508
|
include_total: include_total,
|
|
444
509
|
cursor: cursor,
|
|
445
510
|
fields: fields,
|
|
511
|
+
enrichments: enrichments,
|
|
512
|
+
contacts_per_company: contacts_per_company,
|
|
513
|
+
emails_per_contact: emails_per_contact,
|
|
514
|
+
query: query,
|
|
446
515
|
async_request: false
|
|
447
516
|
)
|
|
448
517
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: outscraper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Outscraper
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|