-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
57 lines (43 loc) · 1.99 KB
/
README
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
51
52
53
54
55
56
57
Yellow Page Scraper is a library for searching various online yellow pages
providers such as switchboard.com and superpages.com.
The search method returns an array of results or an empty list. The minimum
required arguments are keyword, city, and state (passed in that order). The
rest of the arguments should be passed as has options
:provider => :switchboard
:num_results => 10
:num_results => :all
Currently only supports switchboard fully. Superpages (:superpages) and
yellowpages.com (:yellowpages) are on the way.
Each result has at least the name set. Anything missing will be set to nil.
Here is the entire list of possible data found (accessed via result.<data name>):
url - website (often not found or some search url for the provider)
name - business name or person's name
phone - main phone number (sometimes they have additional numbers. currently not getting those)
address - main address
city
state
zip - usually not there
email
provider - which provider was used to find the data
== Usage
require 'ypscraper'
yp = YPScraper.new(:switchboard)
# See how many entires are on the first page
print "Number of results for first page when searching dentist in austin, tx is " +
yp.search("dentist", "austin", "tx").size.to_s
puts
# Get 1st 3 yellow page entries
results = yp.search("dentist", "austin", "tx" , :num_results=>3)
results.each_with_index do |r,i|
puts "#{i} - #{r.name} / #{r.url} / #{r.address} / #{r.url}"
end
# Get all entries for a search
results = yp.search("Periodontics Dentists", "austin", "tx" , :num_results=>:all)
results.each_with_index do |r,i|
puts "#{i} - #{r.name} / #{r.url} / #{r.address} / #{r.url}"
end
== License
Copyright (c) 2009 Taylor Carpenter <[email protected]>
You may use, copy and redistribute this library under the same terms as
{Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the
{MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].