craigler 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +22 -0
- data/README.rdoc +165 -0
- data/Rakefile +58 -0
- data/VERSION.yml +5 -0
- data/craigler.gemspec +57 -0
- data/lib/craigler.rb +36 -0
- data/lib/craigler/constants.rb +501 -0
- data/lib/craigler/search.rb +94 -0
- data/test/craigler_search_test.rb +70 -0
- data/test/craigler_test.rb +33 -0
- data/test/test_helper.rb +16 -0
- metadata +97 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2009 Devin Christensen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
= Craigler
|
2
|
+
|
3
|
+
Search API for craigslist
|
4
|
+
|
5
|
+
== SYNOPSIS:
|
6
|
+
I couldn't decide which API I liked best, so you have two choices.
|
7
|
+
|
8
|
+
Craigler.search(:motorcycles, :in => [:utah, :nevada, :arizona], :for => 'Boulevard M50') do |item|
|
9
|
+
puts item.title
|
10
|
+
puts item.url
|
11
|
+
puts item.time
|
12
|
+
end
|
13
|
+
|
14
|
+
or
|
15
|
+
|
16
|
+
Craigler.find('Boulevard M50', :in => :california, :only => :motorcycles) do |item|
|
17
|
+
puts item.title
|
18
|
+
puts item.url
|
19
|
+
puts item.time
|
20
|
+
end
|
21
|
+
|
22
|
+
You can also create a search object to fetch the results later. When no location or category is given Craigler searches <tt>:all_for_sale_or_wanted</tt> <tt>:in => :anywhere</tt>
|
23
|
+
|
24
|
+
search = Craigler::Search.new('Yamaha')
|
25
|
+
search.results()
|
26
|
+
|
27
|
+
Note that additional calls to <tt>search.results()</tt> will always return the same result set unless refresh is forced
|
28
|
+
search.results(:refresh => true)
|
29
|
+
|
30
|
+
See Craigler::Search for a list of all available options
|
31
|
+
|
32
|
+
=== Supported Categories
|
33
|
+
<tt>:all_for_sale_or_wanted</tt>, <tt>:art_and_crafts</tt>, <tt>:auto_parts</tt>, <tt>:baby_and_kid_stuff</tt>, <tt>:barter</tt>, <tt>:bicycles</tt>, <tt>:boats</tt>, <tt>:books</tt>, <tt>:business</tt>, <tt>:cars_and_trucks</tt>, <tt>:clothing</tt>, <tt>:collectibles</tt>, <tt>:community</tt>, <tt>:computers_and_tech</tt>, <tt>:electronics</tt>, <tt>:event</tt>, <tt>:farm_and_garden</tt>, <tt>:free_stuff</tt>, <tt>:furniture</tt>, <tt>:games_and_toys</tt>, <tt>:garage_sales</tt>, <tt>:general</tt>, <tt>:gigs</tt>, <tt>:household</tt>, <tt>:housing</tt>, <tt>:items_wanted</tt>, <tt>:jewelry</tt>, <tt>:jobs</tt>, <tt>:materials</tt>, <tt>:media</tt>, <tt>:motorcycles</tt>, <tt>:musical_instruments</tt>, <tt>:personals</tt>, <tt>:photo_and_video</tt>, <tt>:recreational_vehicles</tt>, <tt>:resume</tt>, <tt>:services_offered</tt>, <tt>:sporting_goods</tt>, <tt>:tickets</tt>, <tt>:tools</tt>
|
34
|
+
|
35
|
+
=== Supported Locations
|
36
|
+
==== States
|
37
|
+
<tt>:alaska</tt>, <tt>:arizona</tt>, <tt>:arkansas</tt>, <tt>:california</tt>, <tt>:colorado</tt>, <tt>:connecticut</tt>, <tt>:delaware</tt>, <tt>:dc</tt>, <tt>:florida</tt>, <tt>:georgia</tt>, <tt>:hawaii</tt>, <tt>:idaho</tt>, <tt>:illinois</tt>, <tt>:indiana</tt>, <tt>:iowa</tt>, <tt>:kansas</tt>, <tt>:kentucky</tt>, <tt>:louisiana</tt>, <tt>:maine</tt>, <tt>:maryland</tt>, <tt>:mass</tt>, <tt>:michigan</tt>, <tt>:minnesota</tt>, <tt>:mississippi</tt>, <tt>:missouri</tt>, <tt>:montana</tt>, <tt>:nebraska</tt>, <tt>:nevada</tt>, <tt>:n_hampshire</tt>, <tt>:new_jersey</tt>, <tt>:new_mexico</tt>, <tt>:new_york</tt>, <tt>:n_carolina</tt>, <tt>:north_dakota</tt>, <tt>:ohio</tt>, <tt>:oklahoma</tt>, <tt>:oregon</tt>, <tt>:pennsylvania</tt>, <tt>:rhode_island</tt>, <tt>:s_carolina</tt>, <tt>:south_dakota</tt>, <tt>:tennessee</tt>, <tt>:texas</tt>, <tt>:utah</tt>, <tt>:vermont</tt>, <tt>:virginia</tt>, <tt>:washington</tt>, <tt>:west_virginia</tt> <tt>:wisconsin</tt>, <tt>:wyoming</tt>
|
38
|
+
==== Cities
|
39
|
+
===== Alabama
|
40
|
+
<tt>:auburn</tt>,<tt>:bham</tt>,<tt>:columbusga</tt>,<tt>:dothan</tt>,<tt>:shoals</tt>,<tt>:gadsden</tt>,<tt>:huntsville</tt>,<tt>:mobile</tt>,<tt>:montgomery</tt>,<tt>:tuscaloosa</tt>,
|
41
|
+
===== Alaska
|
42
|
+
<tt>:anchorage</tt>,
|
43
|
+
===== Arizona
|
44
|
+
<tt>:flagstaff</tt>,<tt>:mohave</tt>,<tt>:phoenix</tt>,<tt>:prescott</tt>,<tt>:sierravista</tt>,<tt>:tucson</tt>,<tt>:yuma</tt>,
|
45
|
+
===== Arkansas
|
46
|
+
<tt>:fayar</tt>,<tt>:fortsmith</tt>,<tt>:jonesboro</tt>,<tt>:littlerock</tt>,<tt>:memphis</tt>,<tt>:texarkana</tt>,
|
47
|
+
===== California
|
48
|
+
<tt>:sfbay</tt>,<tt>:bakersfield</tt>,<tt>:chico</tt>,<tt>:fresno</tt>,<tt>:goldcountry</tt>,<tt>:humboldt</tt>,<tt>:imperial</tt>,<tt>:inlandempire</tt>,
|
49
|
+
<tt>:losangeles</tt>,<tt>:mendocino</tt>,<tt>:merced</tt>,<tt>:modesto</tt>,<tt>:monterey</tt>,<tt>:orangecounty</tt>,<tt>:palmsprings</tt>,<tt>:redding</tt>,
|
50
|
+
<tt>:reno</tt>,<tt>:sacramento</tt>,<tt>:sandiego</tt>,<tt>:slo</tt>,<tt>:santabarbara</tt>,<tt>:stockton</tt>,<tt>:ventura</tt>,<tt>:visalia</tt>,<tt>:yubasutter</tt>,
|
51
|
+
===== Colorado
|
52
|
+
<tt>:boulder</tt>,<tt>:cosprings</tt>,<tt>:denver</tt>,<tt>:fortcollins</tt>,<tt>:pueblo</tt>,<tt>:rockies</tt>,<tt>:westslope</tt>,
|
53
|
+
===== Connecticut
|
54
|
+
<tt>:newlondon</tt>,<tt>:hartford</tt>,<tt>:newhaven</tt>,<tt>:nwct</tt>,
|
55
|
+
===== Delaware
|
56
|
+
<tt>:delaware</tt>,
|
57
|
+
===== Dc
|
58
|
+
<tt>:washingtondc</tt>,
|
59
|
+
===== Florida
|
60
|
+
<tt>:daytona</tt>,<tt>:keys</tt>,<tt>:fortmyers</tt>,<tt>:gainesville</tt>,<tt>:jacksonville</tt>,<tt>:lakeland</tt>,<tt>:ocala</tt>,<tt>:orlando</tt>,
|
61
|
+
<tt>:panamacity</tt>,<tt>:pensacola</tt>,<tt>:sarasota</tt>,<tt>:miami</tt>,<tt>:spacecoast</tt>,<tt>:staugustine</tt>,<tt>:tallahassee</tt>,<tt>:tampa</tt>,<tt>:treasure</tt>,
|
62
|
+
===== Georgia
|
63
|
+
<tt>:athensga</tt>,<tt>:atlanta</tt>,<tt>:augusta</tt>,<tt>:brunswick</tt>,<tt>:columbusga</tt>,<tt>:macon</tt>,<tt>:savannah</tt>,<tt>:valdosta</tt>,
|
64
|
+
===== Hawaii
|
65
|
+
<tt>:honolulu</tt>,
|
66
|
+
===== Idaho
|
67
|
+
<tt>:boise</tt>,<tt>:eastidaho</tt>,<tt>:pullman</tt>,<tt>:spokane</tt>,<tt>:twinfalls</tt>,
|
68
|
+
===== Illinois
|
69
|
+
<tt>:bn</tt>,<tt>:carbondale</tt>,<tt>:chambana</tt>,<tt>:chicago</tt>,<tt>:decatur</tt>,<tt>:peoria</tt>,<tt>:quadcities</tt>,<tt>:rockford</tt>,<tt>:springfieldil</tt>,<tt>:stlouis</tt>,
|
70
|
+
===== Indiana
|
71
|
+
<tt>:bloomington</tt>,<tt>:evansville</tt>,<tt>:fortwayne</tt>,<tt>:indianapolis</tt>,<tt>:tippecanoe</tt>,<tt>:muncie</tt>,<tt>:southbend</tt>,<tt>:terrahaute</tt>,
|
72
|
+
===== Iowa
|
73
|
+
<tt>:ames</tt>,<tt>:cedarrapids</tt>,<tt>:desmoines</tt>,<tt>:dubuque</tt>,<tt>:iowacity</tt>,<tt>:omaha</tt>,<tt>:quadcities</tt>,<tt>:siouxcity</tt>,<tt>:waterloo</tt>,
|
74
|
+
===== Kansas
|
75
|
+
<tt>:kansascity</tt>,<tt>:lawrence</tt>,<tt>:ksu</tt>,<tt>:topeka</tt>,<tt>:wichita</tt>,
|
76
|
+
===== Kentucky
|
77
|
+
<tt>:bgky</tt>,<tt>:cincinnati</tt>,<tt>:huntington</tt>,<tt>:lexington</tt>,<tt>:louisville</tt>,<tt>:westky</tt>,
|
78
|
+
===== Louisiana
|
79
|
+
<tt>:batonrouge</tt>,<tt>:lafayette</tt>,<tt>:lakecharles</tt>,<tt>:monroe</tt>,<tt>:neworleans</tt>,<tt>:shreveport</tt>,
|
80
|
+
===== Maine
|
81
|
+
<tt>:maine</tt>,
|
82
|
+
===== Maryland
|
83
|
+
<tt>:annapolis</tt>,<tt>:baltimore</tt>,<tt>:easternshore</tt>,<tt>:smd</tt>,<tt>:westmd</tt>,
|
84
|
+
===== Mass
|
85
|
+
<tt>:boston</tt>,<tt>:capecod</tt>,<tt>:southcoast</tt>,<tt>:westernmass</tt>,<tt>:worcester</tt>,
|
86
|
+
===== Michigan
|
87
|
+
<tt>:annarbor</tt>,<tt>:centralmich</tt>,<tt>:detroit</tt>,<tt>:flint</tt>,<tt>:grandrapids</tt>,<tt>:jxn</tt>,<tt>:kalamazoo</tt>,<tt>:lansing</tt>,
|
88
|
+
<tt>:muskegon</tt>,<tt>:nmi</tt>,<tt>:porthuron</tt>,<tt>:saginaw</tt>,<tt>:southbend</tt>,<tt>:swmi</tt>,<tt>:up</tt>,
|
89
|
+
===== Minnesota
|
90
|
+
<tt>:duluth</tt>,<tt>:fargo</tt>,<tt>:mankato</tt>,<tt>:minneapolis</tt>,<tt>:rmn</tt>,<tt>:stcloud</tt>,
|
91
|
+
===== Mississippi
|
92
|
+
<tt>:gulfport</tt>,<tt>:hattiesburg</tt>,<tt>:jackson</tt>,<tt>:memphis</tt>,<tt>:northmiss</tt>,
|
93
|
+
===== Missouri
|
94
|
+
<tt>:columbiamo</tt>,<tt>:joplin</tt>,<tt>:kansascity</tt>,<tt>:semo</tt>,<tt>:springfield</tt>,<tt>:stlouis</tt>,
|
95
|
+
===== Montana
|
96
|
+
<tt>:montana</tt>,
|
97
|
+
===== Nebraska
|
98
|
+
<tt>:grandisland</tt>,<tt>:lincoln</tt>,<tt>:omaha</tt>,<tt>:siouxcity</tt>,
|
99
|
+
===== Nevada
|
100
|
+
<tt>:lasvegas</tt>,<tt>:reno</tt>,
|
101
|
+
===== N hampshire
|
102
|
+
<tt>:nh</tt>,
|
103
|
+
===== New jersey
|
104
|
+
<tt>:cnj</tt>,<tt>:jerseyshore</tt>,<tt>:newjersey</tt>,<tt>:southjersey</tt>,
|
105
|
+
===== New mexico
|
106
|
+
<tt>:albuquerque</tt>,<tt>:farmington</tt>,<tt>:lascruces</tt>,<tt>:roswell</tt>,<tt>:santafe</tt>,
|
107
|
+
===== New york
|
108
|
+
<tt>:albany</tt>,<tt>:binghamton</tt>,<tt>:buffalo</tt>,<tt>:catskills</tt>,<tt>:chautauqua</tt>,<tt>:elmira</tt>,<tt>:hudsonvalley</tt>,<tt>:ithaca</tt>,
|
109
|
+
<tt>:longisland</tt>,<tt>:newyork</tt>,<tt>:plattsburgh</tt>,<tt>:rochester</tt>,<tt>:syracuse</tt>,<tt>:utica</tt>,<tt>:watertown</tt>,
|
110
|
+
===== N carolina
|
111
|
+
<tt>:asheville</tt>,<tt>:boone</tt>,<tt>:charlotte</tt>,<tt>:eastnc</tt>,<tt>:fayetteville</tt>,<tt>:greensboro</tt>,<tt>:hickory</tt>,<tt>:outerbanks</tt>,
|
112
|
+
<tt>:raleigh</tt>,<tt>:wilmington</tt>,<tt>:winstonsalem</tt>,
|
113
|
+
===== North dakota
|
114
|
+
<tt>:fargo</tt>,<tt>:nd</tt>,
|
115
|
+
===== Ohio
|
116
|
+
<tt>:akroncanton</tt>,<tt>:athensohio</tt>,<tt>:cincinnati</tt>,<tt>:cleveland</tt>,<tt>:columbus</tt>,<tt>:dayton</tt>,<tt>:huntington</tt>,<tt>:limaohio</tt>,
|
117
|
+
<tt>:mansfield</tt>,<tt>:parkersburg</tt>,<tt>:sandusky</tt>,<tt>:toledo</tt>,<tt>:wheeling</tt>,<tt>:youngstown</tt>,
|
118
|
+
===== Oklahoma
|
119
|
+
<tt>:fortsmith</tt>,<tt>:lawton</tt>,<tt>:oklahomacity</tt>,<tt>:stillwater</tt>,<tt>:tulsa</tt>,
|
120
|
+
===== Oregon
|
121
|
+
<tt>:bend</tt>,<tt>:corvallis</tt>,<tt>:eastoregon</tt>,<tt>:eugene</tt>,<tt>:medford</tt>,<tt>:oregoncoast</tt>,<tt>:portland</tt>,<tt>:roseburg</tt>,<tt>:salem</tt>,
|
122
|
+
===== Pennsylvania
|
123
|
+
<tt>:altoona</tt>,<tt>:erie</tt>,<tt>:harrisburg</tt>,<tt>:lancaster</tt>,<tt>:allentown</tt>,<tt>:philadelphia</tt>,<tt>:pittsburgh</tt>,<tt>:poconos</tt>,
|
124
|
+
<tt>:reading</tt>,<tt>:scranton</tt>,<tt>:pennstate</tt>,<tt>:williamsport</tt>,<tt>:york</tt>,
|
125
|
+
===== Rhode island
|
126
|
+
<tt>:providence</tt>,
|
127
|
+
===== S carolina
|
128
|
+
<tt>:charleston</tt>,<tt>:columbia</tt>,<tt>:florencesc</tt>,<tt>:greenville</tt>,<tt>:hiltonhead</tt>,<tt>:myrtlebeach</tt>,
|
129
|
+
===== South dakota
|
130
|
+
<tt>:sd</tt>,
|
131
|
+
===== Tennessee
|
132
|
+
<tt>:chattanooga</tt>,<tt>:clarksville</tt>,<tt>:jacksontn</tt>,<tt>:knoxville</tt>,<tt>:memphis</tt>,<tt>:nashville</tt>,<tt>:tricities</tt>,
|
133
|
+
===== Texas
|
134
|
+
<tt>:abilene</tt>,<tt>:amarillo</tt>,<tt>:austin</tt>,<tt>:beaumont</tt>,<tt>:brownsville</tt>,<tt>:collegestation</tt>,<tt>:corpuschristi</tt>,<tt>:dallas</tt>,
|
135
|
+
<tt>:elpaso</tt>,<tt>:galveston</tt>,<tt>:houston</tt>,<tt>:killeen</tt>,<tt>:laredo</tt>,<tt>:lubbock</tt>,<tt>:mcallen</tt>,<tt>:odessa</tt>,<tt>:sanantonio</tt>,
|
136
|
+
<tt>:sanmarcos</tt>,<tt>:texarkana</tt>,<tt>:easttexas</tt>,<tt>:victoriatx</tt>,<tt>:waco</tt>,<tt>:wichitafalls</tt>,
|
137
|
+
===== Utah
|
138
|
+
<tt>:logan</tt>,<tt>:ogden</tt>,<tt>:provo</tt>,<tt>:saltlakecity</tt>,<tt>:stgeorge</tt>,
|
139
|
+
===== Vermont
|
140
|
+
<tt>:burlington</tt>,
|
141
|
+
===== Virginia
|
142
|
+
<tt>:blacksburg</tt>,<tt>:charlottesville</tt>,<tt>:danville</tt>,<tt>:easternshore</tt>,<tt>:fredericksburg</tt>,<tt>:norfolk</tt>,<tt>:harrisonburg</tt>,
|
143
|
+
<tt>:lynchburg</tt>,<tt>:richmond</tt>,<tt>:roanoke</tt>,
|
144
|
+
===== Washington
|
145
|
+
<tt>:bellingham</tt>,<tt>:kpr</tt>,<tt>:olympic</tt>,<tt>:pullman</tt>,<tt>:seattle</tt>,<tt>:skagit</tt>,<tt>:spokane</tt>,<tt>:wenatchee</tt>,<tt>:yakima</tt>,
|
146
|
+
===== West virginia
|
147
|
+
<tt>:charlestonwv</tt>,<tt>:huntington</tt>,<tt>:martinsburg</tt>,<tt>:morgantown</tt>,<tt>:parkersburg</tt>,<tt>:wv</tt>,<tt>:wheeling</tt>,
|
148
|
+
===== Wisconsin
|
149
|
+
<tt>:appleton</tt>,<tt>:duluth</tt>,<tt>:eauclaire</tt>,<tt>:greenbay</tt>,<tt>:janesville</tt>,<tt>:racine</tt>,<tt>:lacrosse</tt>,<tt>:madison</tt>,
|
150
|
+
<tt>:milwaukee</tt>,<tt>:sheboygan</tt>,<tt>:wausau</tt>
|
151
|
+
|
152
|
+
|
153
|
+
Or use <tt>:in => :anywhere</tt> to search all supported locations.
|
154
|
+
|
155
|
+
== REQUIREMENTS:
|
156
|
+
|
157
|
+
* Hpricot
|
158
|
+
|
159
|
+
== INSTALL:
|
160
|
+
|
161
|
+
* sudo gem install quixoten-craigler
|
162
|
+
|
163
|
+
== Copyright
|
164
|
+
|
165
|
+
Copyright (c) 2009 Devin Christensen. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "craigler"
|
8
|
+
gem.summary = %Q{Search API for craigslist}
|
9
|
+
gem.email = "quixoten@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/threetrieslater/craigler"
|
11
|
+
gem.authors = ["Devin Christensen"]
|
12
|
+
gem.add_development_dependency "shoulda", ">= 2.10.3"
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/*_test.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
if File.exist?('VERSION.yml')
|
46
|
+
config = YAML.load(File.read('VERSION.yml'))
|
47
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
48
|
+
else
|
49
|
+
version = ""
|
50
|
+
end
|
51
|
+
|
52
|
+
rdoc.rdoc_dir = 'rdoc'
|
53
|
+
rdoc.title = "Craigler #{version}"
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
rdoc.rdoc_files.include('README.rdoc', 'LICENSE')
|
56
|
+
rdoc.main = 'README.rdoc'
|
57
|
+
end
|
58
|
+
|
data/VERSION.yml
ADDED
data/craigler.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{craigler}
|
8
|
+
s.version = "1.3.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Devin Christensen"]
|
12
|
+
s.date = %q{2010-09-05}
|
13
|
+
s.email = %q{quixoten@gmail.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION.yml",
|
25
|
+
"craigler.gemspec",
|
26
|
+
"lib/craigler.rb",
|
27
|
+
"lib/craigler/constants.rb",
|
28
|
+
"lib/craigler/search.rb",
|
29
|
+
"test/craigler_search_test.rb",
|
30
|
+
"test/craigler_test.rb",
|
31
|
+
"test/test_helper.rb"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/threetrieslater/craigler}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
37
|
+
s.summary = %q{Search API for craigslist}
|
38
|
+
s.test_files = [
|
39
|
+
"test/craigler_search_test.rb",
|
40
|
+
"test/craigler_test.rb",
|
41
|
+
"test/test_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.10.3"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.3"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/lib/craigler.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'Hpricot'
|
3
|
+
|
4
|
+
require 'craigler/constants'
|
5
|
+
require 'craigler/search'
|
6
|
+
|
7
|
+
module Craigler
|
8
|
+
|
9
|
+
# :stopdoc:
|
10
|
+
class CraiglerError < StandardError; end
|
11
|
+
class InvalidCategory < CraiglerError; end
|
12
|
+
class InvalidSearchTerm < CraiglerError; end
|
13
|
+
class InvalidLocation < CraiglerError; end
|
14
|
+
# :startdoc:
|
15
|
+
|
16
|
+
class << self
|
17
|
+
# Interface to Search that may or may not be more readable
|
18
|
+
#
|
19
|
+
# Supports all options of Search#new except <tt>:only</tt>, as it's supplied through the <tt>category</tt> parameter
|
20
|
+
def search(category, options = {})
|
21
|
+
options = options.merge({ :only => category })
|
22
|
+
results = Search.new(options.delete(:for), options).results()
|
23
|
+
results.each {|result| yield(result) } if block_given?
|
24
|
+
results
|
25
|
+
end
|
26
|
+
|
27
|
+
# Interface to Search that somewhat mimics ActiveRecord#find
|
28
|
+
#
|
29
|
+
# Supports all the options of Search#new
|
30
|
+
def find(search_term, options = {})
|
31
|
+
results = Search.new(search_term, options).results()
|
32
|
+
results.each {|result| yield(result) } if block_given?
|
33
|
+
results
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,501 @@
|
|
1
|
+
module Craigler
|
2
|
+
|
3
|
+
# :stopdoc:
|
4
|
+
RESULTS_PER_PAGE = 25
|
5
|
+
|
6
|
+
LOCATIONS = {
|
7
|
+
:alabama => ['http://auburn.craigslist.org/','http://bham.craigslist.org/','http://columbusga.craigslist.org/','http://dothan.craigslist.org/','http://shoals.craigslist.org/','http://gadsden.craigslist.org/','http://huntsville.craigslist.org/','http://mobile.craigslist.org/','http://montgomery.craigslist.org/','http://tuscaloosa.craigslist.org/'],
|
8
|
+
:alaska => ['http://anchorage.craigslist.org/'],
|
9
|
+
:arizona => ['http://flagstaff.craigslist.org/','http://mohave.craigslist.org/','http://phoenix.craigslist.org/','http://prescott.craigslist.org/','http://sierravista.craigslist.org/','http://tucson.craigslist.org/','http://yuma.craigslist.org/'],
|
10
|
+
:arkansas => ['http://fayar.craigslist.org/','http://fortsmith.craigslist.org/','http://jonesboro.craigslist.org/','http://littlerock.craigslist.org/','http://memphis.craigslist.org/','http://texarkana.craigslist.org/'],
|
11
|
+
:california => ['http://sfbay.craigslist.org/','http://bakersfield.craigslist.org/','http://chico.craigslist.org/','http://fresno.craigslist.org/','http://goldcountry.craigslist.org/','http://humboldt.craigslist.org/','http://imperial.craigslist.org/','http://inlandempire.craigslist.org/','http://losangeles.craigslist.org/','http://mendocino.craigslist.org/','http://merced.craigslist.org/','http://modesto.craigslist.org/','http://monterey.craigslist.org/','http://orangecounty.craigslist.org/','http://palmsprings.craigslist.org/','http://redding.craigslist.org/','http://reno.craigslist.org/','http://sacramento.craigslist.org/','http://sandiego.craigslist.org/','http://slo.craigslist.org/','http://santabarbara.craigslist.org/','http://stockton.craigslist.org/','http://ventura.craigslist.org/','http://visalia.craigslist.org/','http://yubasutter.craigslist.org/'],
|
12
|
+
:colorado => ['http://boulder.craigslist.org/','http://cosprings.craigslist.org/','http://denver.craigslist.org/','http://fortcollins.craigslist.org/','http://pueblo.craigslist.org/','http://rockies.craigslist.org/','http://westslope.craigslist.org/'],
|
13
|
+
:connecticut => ['http://newlondon.craigslist.org/','http://hartford.craigslist.org/','http://newhaven.craigslist.org/','http://nwct.craigslist.org/'],
|
14
|
+
:delaware => ['http://delaware.craigslist.org/'],
|
15
|
+
:dc => ['http://washingtondc.craigslist.org/'],
|
16
|
+
:florida => ['http://daytona.craigslist.org/','http://keys.craigslist.org/','http://fortmyers.craigslist.org/','http://gainesville.craigslist.org/','http://jacksonville.craigslist.org/','http://lakeland.craigslist.org/','http://ocala.craigslist.org/','http://orlando.craigslist.org/','http://panamacity.craigslist.org/','http://pensacola.craigslist.org/','http://sarasota.craigslist.org/','http://miami.craigslist.org/','http://spacecoast.craigslist.org/','http://staugustine.craigslist.org/','http://tallahassee.craigslist.org/','http://tampa.craigslist.org/','http://treasure.craigslist.org/'],
|
17
|
+
:georgia => ['http://athensga.craigslist.org/','http://atlanta.craigslist.org/','http://augusta.craigslist.org/','http://brunswick.craigslist.org/','http://columbusga.craigslist.org/','http://macon.craigslist.org/','http://savannah.craigslist.org/','http://valdosta.craigslist.org/'],
|
18
|
+
:hawaii => ['http://honolulu.craigslist.org/'],
|
19
|
+
:idaho => ['http://boise.craigslist.org/','http://eastidaho.craigslist.org/','http://pullman.craigslist.org/','http://spokane.craigslist.org/','http://twinfalls.craigslist.org/'],
|
20
|
+
:illinois => ['http://bn.craigslist.org/','http://carbondale.craigslist.org/','http://chambana.craigslist.org/','http://chicago.craigslist.org/','http://decatur.craigslist.org/','http://peoria.craigslist.org/','http://quadcities.craigslist.org/','http://rockford.craigslist.org/','http://springfieldil.craigslist.org/','http://stlouis.craigslist.org/'],
|
21
|
+
:indiana => ['http://bloomington.craigslist.org/','http://evansville.craigslist.org/','http://fortwayne.craigslist.org/','http://indianapolis.craigslist.org/','http://tippecanoe.craigslist.org/','http://muncie.craigslist.org/','http://southbend.craigslist.org/','http://terrahaute.craigslist.org/'],
|
22
|
+
:iowa => ['http://ames.craigslist.org/','http://cedarrapids.craigslist.org/','http://desmoines.craigslist.org/','http://dubuque.craigslist.org/','http://iowacity.craigslist.org/','http://omaha.craigslist.org/','http://quadcities.craigslist.org/','http://siouxcity.craigslist.org/','http://waterloo.craigslist.org/'],
|
23
|
+
:kansas => ['http://kansascity.craigslist.org/','http://lawrence.craigslist.org/','http://ksu.craigslist.org/','http://topeka.craigslist.org/','http://wichita.craigslist.org/'],
|
24
|
+
:kentucky => ['http://bgky.craigslist.org/','http://cincinnati.craigslist.org/','http://huntington.craigslist.org/','http://lexington.craigslist.org/','http://louisville.craigslist.org/','http://westky.craigslist.org/'],
|
25
|
+
:louisiana => ['http://batonrouge.craigslist.org/','http://lafayette.craigslist.org/','http://lakecharles.craigslist.org/','http://monroe.craigslist.org/','http://neworleans.craigslist.org/','http://shreveport.craigslist.org/'],
|
26
|
+
:maine => ['http://maine.craigslist.org/'],
|
27
|
+
:maryland => ['http://annapolis.craigslist.org/','http://baltimore.craigslist.org/','http://easternshore.craigslist.org/','http://smd.craigslist.org/','http://westmd.craigslist.org/'],
|
28
|
+
:mass => ['http://boston.craigslist.org/','http://capecod.craigslist.org/','http://southcoast.craigslist.org/','http://westernmass.craigslist.org/','http://worcester.craigslist.org/'],
|
29
|
+
:michigan => ['http://annarbor.craigslist.org/','http://centralmich.craigslist.org/','http://detroit.craigslist.org/','http://flint.craigslist.org/','http://grandrapids.craigslist.org/','http://jxn.craigslist.org/','http://kalamazoo.craigslist.org/','http://lansing.craigslist.org/','http://muskegon.craigslist.org/','http://nmi.craigslist.org/','http://porthuron.craigslist.org/','http://saginaw.craigslist.org/','http://southbend.craigslist.org/','http://swmi.craigslist.org/','http://up.craigslist.org/'],
|
30
|
+
:minnesota => ['http://duluth.craigslist.org/','http://fargo.craigslist.org/','http://mankato.craigslist.org/','http://minneapolis.craigslist.org/','http://rmn.craigslist.org/','http://stcloud.craigslist.org/'],
|
31
|
+
:mississippi => ['http://gulfport.craigslist.org/','http://hattiesburg.craigslist.org/','http://jackson.craigslist.org/','http://memphis.craigslist.org/','http://northmiss.craigslist.org/'],
|
32
|
+
:missouri => ['http://columbiamo.craigslist.org/','http://joplin.craigslist.org/','http://kansascity.craigslist.org/','http://semo.craigslist.org/','http://springfield.craigslist.org/','http://stlouis.craigslist.org/'],
|
33
|
+
:montana => ['http://montana.craigslist.org/'],
|
34
|
+
:nebraska => ['http://grandisland.craigslist.org/','http://lincoln.craigslist.org/','http://omaha.craigslist.org/','http://siouxcity.craigslist.org/'],
|
35
|
+
:nevada => ['http://lasvegas.craigslist.org/','http://reno.craigslist.org/'],
|
36
|
+
:n_hampshire => ['http://nh.craigslist.org/'],
|
37
|
+
:new_jersey => ['http://cnj.craigslist.org/','http://jerseyshore.craigslist.org/','http://newjersey.craigslist.org/','http://southjersey.craigslist.org/'],
|
38
|
+
:new_mexico => ['http://albuquerque.craigslist.org/','http://farmington.craigslist.org/','http://lascruces.craigslist.org/','http://roswell.craigslist.org/','http://santafe.craigslist.org/'],
|
39
|
+
:new_york => ['http://albany.craigslist.org/','http://binghamton.craigslist.org/','http://buffalo.craigslist.org/','http://catskills.craigslist.org/','http://chautauqua.craigslist.org/','http://elmira.craigslist.org/','http://hudsonvalley.craigslist.org/','http://ithaca.craigslist.org/','http://longisland.craigslist.org/','http://newyork.craigslist.org/','http://plattsburgh.craigslist.org/','http://rochester.craigslist.org/','http://syracuse.craigslist.org/','http://utica.craigslist.org/','http://watertown.craigslist.org/'],
|
40
|
+
:n_carolina => ['http://asheville.craigslist.org/','http://boone.craigslist.org/','http://charlotte.craigslist.org/','http://eastnc.craigslist.org/','http://fayetteville.craigslist.org/','http://greensboro.craigslist.org/','http://hickory.craigslist.org/','http://outerbanks.craigslist.org/','http://raleigh.craigslist.org/','http://wilmington.craigslist.org/','http://winstonsalem.craigslist.org/'],
|
41
|
+
:north_dakota => ['http://fargo.craigslist.org/','http://nd.craigslist.org/'],
|
42
|
+
:ohio => ['http://akroncanton.craigslist.org/','http://athensohio.craigslist.org/','http://cincinnati.craigslist.org/','http://cleveland.craigslist.org/','http://columbus.craigslist.org/','http://dayton.craigslist.org/','http://huntington.craigslist.org/','http://limaohio.craigslist.org/','http://mansfield.craigslist.org/','http://parkersburg.craigslist.org/','http://sandusky.craigslist.org/','http://toledo.craigslist.org/','http://wheeling.craigslist.org/','http://youngstown.craigslist.org/'],
|
43
|
+
:oklahoma => ['http://fortsmith.craigslist.org/','http://lawton.craigslist.org/','http://oklahomacity.craigslist.org/','http://stillwater.craigslist.org/','http://tulsa.craigslist.org/'],
|
44
|
+
:oregon => ['http://bend.craigslist.org/','http://corvallis.craigslist.org/','http://eastoregon.craigslist.org/','http://eugene.craigslist.org/','http://medford.craigslist.org/','http://oregoncoast.craigslist.org/','http://portland.craigslist.org/','http://roseburg.craigslist.org/','http://salem.craigslist.org/'],
|
45
|
+
:pennsylvania => ['http://altoona.craigslist.org/','http://erie.craigslist.org/','http://harrisburg.craigslist.org/','http://lancaster.craigslist.org/','http://allentown.craigslist.org/','http://philadelphia.craigslist.org/','http://pittsburgh.craigslist.org/','http://poconos.craigslist.org/','http://reading.craigslist.org/','http://scranton.craigslist.org/','http://pennstate.craigslist.org/','http://williamsport.craigslist.org/','http://york.craigslist.org/'],
|
46
|
+
:rhode_island => ['http://providence.craigslist.org/'],
|
47
|
+
:s_carolina => ['http://charleston.craigslist.org/','http://columbia.craigslist.org/','http://florencesc.craigslist.org/','http://greenville.craigslist.org/','http://hiltonhead.craigslist.org/','http://myrtlebeach.craigslist.org/'],
|
48
|
+
:south_dakota => ['http://sd.craigslist.org/'],
|
49
|
+
:tennessee => ['http://chattanooga.craigslist.org/','http://clarksville.craigslist.org/','http://jacksontn.craigslist.org/','http://knoxville.craigslist.org/','http://memphis.craigslist.org/','http://nashville.craigslist.org/','http://tricities.craigslist.org/'],
|
50
|
+
:texas => ['http://abilene.craigslist.org/','http://amarillo.craigslist.org/','http://austin.craigslist.org/','http://beaumont.craigslist.org/','http://brownsville.craigslist.org/','http://collegestation.craigslist.org/','http://corpuschristi.craigslist.org/','http://dallas.craigslist.org/','http://elpaso.craigslist.org/','http://galveston.craigslist.org/','http://houston.craigslist.org/','http://killeen.craigslist.org/','http://laredo.craigslist.org/','http://lubbock.craigslist.org/','http://mcallen.craigslist.org/','http://odessa.craigslist.org/','http://sanantonio.craigslist.org/','http://sanmarcos.craigslist.org/','http://texarkana.craigslist.org/','http://easttexas.craigslist.org/','http://victoriatx.craigslist.org/','http://waco.craigslist.org/','http://wichitafalls.craigslist.org/'],
|
51
|
+
:utah => ['http://logan.craigslist.org/','http://ogden.craigslist.org/','http://provo.craigslist.org/','http://saltlakecity.craigslist.org/','http://stgeorge.craigslist.org/'],
|
52
|
+
:vermont => ['http://burlington.craigslist.org/'],
|
53
|
+
:virginia => ['http://blacksburg.craigslist.org/','http://charlottesville.craigslist.org/','http://danville.craigslist.org/','http://easternshore.craigslist.org/','http://fredericksburg.craigslist.org/','http://norfolk.craigslist.org/','http://harrisonburg.craigslist.org/','http://lynchburg.craigslist.org/','http://richmond.craigslist.org/','http://roanoke.craigslist.org/'],
|
54
|
+
:washington => ['http://bellingham.craigslist.org/','http://kpr.craigslist.org/','http://olympic.craigslist.org/','http://pullman.craigslist.org/','http://seattle.craigslist.org/','http://skagit.craigslist.org/','http://spokane.craigslist.org/','http://wenatchee.craigslist.org/','http://yakima.craigslist.org/'],
|
55
|
+
:west_virginia => ['http://charlestonwv.craigslist.org/','http://huntington.craigslist.org/','http://martinsburg.craigslist.org/','http://morgantown.craigslist.org/','http://parkersburg.craigslist.org/','http://wv.craigslist.org/','http://wheeling.craigslist.org/'],
|
56
|
+
:wisconsin => ['http://appleton.craigslist.org/','http://duluth.craigslist.org/','http://eauclaire.craigslist.org/','http://greenbay.craigslist.org/','http://janesville.craigslist.org/','http://racine.craigslist.org/','http://lacrosse.craigslist.org/','http://madison.craigslist.org/','http://milwaukee.craigslist.org/','http://sheboygan.craigslist.org/','http://wausau.craigslist.org/'],
|
57
|
+
:wyoming => ['http://wyoming.craigslist.org/'],
|
58
|
+
# Alabama
|
59
|
+
:auburn => ['http://auburn.craigslist.org/'],
|
60
|
+
:bham => ['http://bham.craigslist.org/'],
|
61
|
+
:columbusga => ['http://columbusga.craigslist.org/'],
|
62
|
+
:dothan => ['http://dothan.craigslist.org/'],
|
63
|
+
:shoals => ['http://shoals.craigslist.org/'],
|
64
|
+
:gadsden => ['http://gadsden.craigslist.org/'],
|
65
|
+
:huntsville => ['http://huntsville.craigslist.org/'],
|
66
|
+
:mobile => ['http://mobile.craigslist.org/'],
|
67
|
+
:montgomery => ['http://montgomery.craigslist.org/'],
|
68
|
+
:tuscaloosa => ['http://tuscaloosa.craigslist.org/'],
|
69
|
+
# Alaska =
|
70
|
+
:anchorage => ['http://anchorage.craigslist.org/'],
|
71
|
+
# Arizona =
|
72
|
+
:flagstaff => ['http://flagstaff.craigslist.org/'],
|
73
|
+
:mohave => ['http://mohave.craigslist.org/'],
|
74
|
+
:phoenix => ['http://phoenix.craigslist.org/'],
|
75
|
+
:prescott => ['http://prescott.craigslist.org/'],
|
76
|
+
:sierravista => ['http://sierravista.craigslist.org/'],
|
77
|
+
:tucson => ['http://tucson.craigslist.org/'],
|
78
|
+
:yuma => ['http://yuma.craigslist.org/'],
|
79
|
+
# Arkansas =
|
80
|
+
:fayar => ['http://fayar.craigslist.org/'],
|
81
|
+
:fortsmith => ['http://fortsmith.craigslist.org/'],
|
82
|
+
:jonesboro => ['http://jonesboro.craigslist.org/'],
|
83
|
+
:littlerock => ['http://littlerock.craigslist.org/'],
|
84
|
+
:memphis => ['http://memphis.craigslist.org/'],
|
85
|
+
:texarkana => ['http://texarkana.craigslist.org/'],
|
86
|
+
# California =
|
87
|
+
:sfbay => ['http://sfbay.craigslist.org/'],
|
88
|
+
:bakersfield => ['http://bakersfield.craigslist.org/'],
|
89
|
+
:chico => ['http://chico.craigslist.org/'],
|
90
|
+
:fresno => ['http://fresno.craigslist.org/'],
|
91
|
+
:goldcountry => ['http://goldcountry.craigslist.org/'],
|
92
|
+
:humboldt => ['http://humboldt.craigslist.org/'],
|
93
|
+
:imperial => ['http://imperial.craigslist.org/'],
|
94
|
+
:inlandempire => ['http://inlandempire.craigslist.org/'],
|
95
|
+
:losangeles => ['http://losangeles.craigslist.org/'],
|
96
|
+
:mendocino => ['http://mendocino.craigslist.org/'],
|
97
|
+
:merced => ['http://merced.craigslist.org/'],
|
98
|
+
:modesto => ['http://modesto.craigslist.org/'],
|
99
|
+
:monterey => ['http://monterey.craigslist.org/'],
|
100
|
+
:orangecounty => ['http://orangecounty.craigslist.org/'],
|
101
|
+
:palmsprings => ['http://palmsprings.craigslist.org/'],
|
102
|
+
:redding => ['http://redding.craigslist.org/'],
|
103
|
+
:reno => ['http://reno.craigslist.org/'],
|
104
|
+
:sacramento => ['http://sacramento.craigslist.org/'],
|
105
|
+
:sandiego => ['http://sandiego.craigslist.org/'],
|
106
|
+
:slo => ['http://slo.craigslist.org/'],
|
107
|
+
:santabarbara => ['http://santabarbara.craigslist.org/'],
|
108
|
+
:stockton => ['http://stockton.craigslist.org/'],
|
109
|
+
:ventura => ['http://ventura.craigslist.org/'],
|
110
|
+
:visalia => ['http://visalia.craigslist.org/'],
|
111
|
+
:yubasutter => ['http://yubasutter.craigslist.org/'],
|
112
|
+
# Colorado =
|
113
|
+
:boulder => ['http://boulder.craigslist.org/'],
|
114
|
+
:cosprings => ['http://cosprings.craigslist.org/'],
|
115
|
+
:denver => ['http://denver.craigslist.org/'],
|
116
|
+
:fortcollins => ['http://fortcollins.craigslist.org/'],
|
117
|
+
:pueblo => ['http://pueblo.craigslist.org/'],
|
118
|
+
:rockies => ['http://rockies.craigslist.org/'],
|
119
|
+
:westslope => ['http://westslope.craigslist.org/'],
|
120
|
+
# Connecticut =
|
121
|
+
:newlondon => ['http://newlondon.craigslist.org/'],
|
122
|
+
:hartford => ['http://hartford.craigslist.org/'],
|
123
|
+
:newhaven => ['http://newhaven.craigslist.org/'],
|
124
|
+
:nwct => ['http://nwct.craigslist.org/'],
|
125
|
+
# Delaware =
|
126
|
+
:delaware => ['http://delaware.craigslist.org/'],
|
127
|
+
# Dc =
|
128
|
+
:washingtondc => ['http://washingtondc.craigslist.org/'],
|
129
|
+
# Florida =
|
130
|
+
:daytona => ['http://daytona.craigslist.org/'],
|
131
|
+
:keys => ['http://keys.craigslist.org/'],
|
132
|
+
:fortmyers => ['http://fortmyers.craigslist.org/'],
|
133
|
+
:gainesville => ['http://gainesville.craigslist.org/'],
|
134
|
+
:jacksonville => ['http://jacksonville.craigslist.org/'],
|
135
|
+
:lakeland => ['http://lakeland.craigslist.org/'],
|
136
|
+
:ocala => ['http://ocala.craigslist.org/'],
|
137
|
+
:orlando => ['http://orlando.craigslist.org/'],
|
138
|
+
:panamacity => ['http://panamacity.craigslist.org/'],
|
139
|
+
:pensacola => ['http://pensacola.craigslist.org/'],
|
140
|
+
:sarasota => ['http://sarasota.craigslist.org/'],
|
141
|
+
:miami => ['http://miami.craigslist.org/'],
|
142
|
+
:spacecoast => ['http://spacecoast.craigslist.org/'],
|
143
|
+
:staugustine => ['http://staugustine.craigslist.org/'],
|
144
|
+
:tallahassee => ['http://tallahassee.craigslist.org/'],
|
145
|
+
:tampa => ['http://tampa.craigslist.org/'],
|
146
|
+
:treasure => ['http://treasure.craigslist.org/'],
|
147
|
+
# Georgia =
|
148
|
+
:athensga => ['http://athensga.craigslist.org/'],
|
149
|
+
:atlanta => ['http://atlanta.craigslist.org/'],
|
150
|
+
:augusta => ['http://augusta.craigslist.org/'],
|
151
|
+
:brunswick => ['http://brunswick.craigslist.org/'],
|
152
|
+
:columbusga => ['http://columbusga.craigslist.org/'],
|
153
|
+
:macon => ['http://macon.craigslist.org/'],
|
154
|
+
:savannah => ['http://savannah.craigslist.org/'],
|
155
|
+
:valdosta => ['http://valdosta.craigslist.org/'],
|
156
|
+
# Hawaii =
|
157
|
+
:honolulu => ['http://honolulu.craigslist.org/'],
|
158
|
+
# Idaho =
|
159
|
+
:boise => ['http://boise.craigslist.org/'],
|
160
|
+
:eastidaho => ['http://eastidaho.craigslist.org/'],
|
161
|
+
:pullman => ['http://pullman.craigslist.org/'],
|
162
|
+
:spokane => ['http://spokane.craigslist.org/'],
|
163
|
+
:twinfalls => ['http://twinfalls.craigslist.org/'],
|
164
|
+
# Illinois =
|
165
|
+
:bn => ['http://bn.craigslist.org/'],
|
166
|
+
:carbondale => ['http://carbondale.craigslist.org/'],
|
167
|
+
:chambana => ['http://chambana.craigslist.org/'],
|
168
|
+
:chicago => ['http://chicago.craigslist.org/'],
|
169
|
+
:decatur => ['http://decatur.craigslist.org/'],
|
170
|
+
:peoria => ['http://peoria.craigslist.org/'],
|
171
|
+
:quadcities => ['http://quadcities.craigslist.org/'],
|
172
|
+
:rockford => ['http://rockford.craigslist.org/'],
|
173
|
+
:springfieldil => ['http://springfieldil.craigslist.org/'],
|
174
|
+
:stlouis => ['http://stlouis.craigslist.org/'],
|
175
|
+
# Indiana =
|
176
|
+
:bloomington => ['http://bloomington.craigslist.org/'],
|
177
|
+
:evansville => ['http://evansville.craigslist.org/'],
|
178
|
+
:fortwayne => ['http://fortwayne.craigslist.org/'],
|
179
|
+
:indianapolis => ['http://indianapolis.craigslist.org/'],
|
180
|
+
:tippecanoe => ['http://tippecanoe.craigslist.org/'],
|
181
|
+
:muncie => ['http://muncie.craigslist.org/'],
|
182
|
+
:southbend => ['http://southbend.craigslist.org/'],
|
183
|
+
:terrahaute => ['http://terrahaute.craigslist.org/'],
|
184
|
+
# Iowa =
|
185
|
+
:ames => ['http://ames.craigslist.org/'],
|
186
|
+
:cedarrapids => ['http://cedarrapids.craigslist.org/'],
|
187
|
+
:desmoines => ['http://desmoines.craigslist.org/'],
|
188
|
+
:dubuque => ['http://dubuque.craigslist.org/'],
|
189
|
+
:iowacity => ['http://iowacity.craigslist.org/'],
|
190
|
+
:omaha => ['http://omaha.craigslist.org/'],
|
191
|
+
:quadcities => ['http://quadcities.craigslist.org/'],
|
192
|
+
:siouxcity => ['http://siouxcity.craigslist.org/'],
|
193
|
+
:waterloo => ['http://waterloo.craigslist.org/'],
|
194
|
+
# Kansas =
|
195
|
+
:kansascity => ['http://kansascity.craigslist.org/'],
|
196
|
+
:lawrence => ['http://lawrence.craigslist.org/'],
|
197
|
+
:ksu => ['http://ksu.craigslist.org/'],
|
198
|
+
:topeka => ['http://topeka.craigslist.org/'],
|
199
|
+
:wichita => ['http://wichita.craigslist.org/'],
|
200
|
+
# Kentucky =
|
201
|
+
:bgky => ['http://bgky.craigslist.org/'],
|
202
|
+
:cincinnati => ['http://cincinnati.craigslist.org/'],
|
203
|
+
:huntington => ['http://huntington.craigslist.org/'],
|
204
|
+
:lexington => ['http://lexington.craigslist.org/'],
|
205
|
+
:louisville => ['http://louisville.craigslist.org/'],
|
206
|
+
:westky => ['http://westky.craigslist.org/'],
|
207
|
+
# Louisiana =
|
208
|
+
:batonrouge => ['http://batonrouge.craigslist.org/'],
|
209
|
+
:lafayette => ['http://lafayette.craigslist.org/'],
|
210
|
+
:lakecharles => ['http://lakecharles.craigslist.org/'],
|
211
|
+
:monroe => ['http://monroe.craigslist.org/'],
|
212
|
+
:neworleans => ['http://neworleans.craigslist.org/'],
|
213
|
+
:shreveport => ['http://shreveport.craigslist.org/'],
|
214
|
+
# Maine =
|
215
|
+
:maine => ['http://maine.craigslist.org/'],
|
216
|
+
# Maryland =
|
217
|
+
:annapolis => ['http://annapolis.craigslist.org/'],
|
218
|
+
:baltimore => ['http://baltimore.craigslist.org/'],
|
219
|
+
:easternshore => ['http://easternshore.craigslist.org/'],
|
220
|
+
:smd => ['http://smd.craigslist.org/'],
|
221
|
+
:westmd => ['http://westmd.craigslist.org/'],
|
222
|
+
# Mass =
|
223
|
+
:boston => ['http://boston.craigslist.org/'],
|
224
|
+
:capecod => ['http://capecod.craigslist.org/'],
|
225
|
+
:southcoast => ['http://southcoast.craigslist.org/'],
|
226
|
+
:westernmass => ['http://westernmass.craigslist.org/'],
|
227
|
+
:worcester => ['http://worcester.craigslist.org/'],
|
228
|
+
# Michigan =
|
229
|
+
:annarbor => ['http://annarbor.craigslist.org/'],
|
230
|
+
:centralmich => ['http://centralmich.craigslist.org/'],
|
231
|
+
:detroit => ['http://detroit.craigslist.org/'],
|
232
|
+
:flint => ['http://flint.craigslist.org/'],
|
233
|
+
:grandrapids => ['http://grandrapids.craigslist.org/'],
|
234
|
+
:jxn => ['http://jxn.craigslist.org/'],
|
235
|
+
:kalamazoo => ['http://kalamazoo.craigslist.org/'],
|
236
|
+
:lansing => ['http://lansing.craigslist.org/'],
|
237
|
+
:muskegon => ['http://muskegon.craigslist.org/'],
|
238
|
+
:nmi => ['http://nmi.craigslist.org/'],
|
239
|
+
:porthuron => ['http://porthuron.craigslist.org/'],
|
240
|
+
:saginaw => ['http://saginaw.craigslist.org/'],
|
241
|
+
:southbend => ['http://southbend.craigslist.org/'],
|
242
|
+
:swmi => ['http://swmi.craigslist.org/'],
|
243
|
+
:up => ['http://up.craigslist.org/'],
|
244
|
+
# Minnesota =
|
245
|
+
:duluth => ['http://duluth.craigslist.org/'],
|
246
|
+
:fargo => ['http://fargo.craigslist.org/'],
|
247
|
+
:mankato => ['http://mankato.craigslist.org/'],
|
248
|
+
:minneapolis => ['http://minneapolis.craigslist.org/'],
|
249
|
+
:rmn => ['http://rmn.craigslist.org/'],
|
250
|
+
:stcloud => ['http://stcloud.craigslist.org/'],
|
251
|
+
# Mississippi =
|
252
|
+
:gulfport => ['http://gulfport.craigslist.org/'],
|
253
|
+
:hattiesburg => ['http://hattiesburg.craigslist.org/'],
|
254
|
+
:jackson => ['http://jackson.craigslist.org/'],
|
255
|
+
:memphis => ['http://memphis.craigslist.org/'],
|
256
|
+
:northmiss => ['http://northmiss.craigslist.org/'],
|
257
|
+
# Missouri =
|
258
|
+
:columbiamo => ['http://columbiamo.craigslist.org/'],
|
259
|
+
:joplin => ['http://joplin.craigslist.org/'],
|
260
|
+
:kansascity => ['http://kansascity.craigslist.org/'],
|
261
|
+
:semo => ['http://semo.craigslist.org/'],
|
262
|
+
:springfield => ['http://springfield.craigslist.org/'],
|
263
|
+
:stlouis => ['http://stlouis.craigslist.org/'],
|
264
|
+
# Montana =
|
265
|
+
:montana => ['http://montana.craigslist.org/'],
|
266
|
+
# Nebraska =
|
267
|
+
:grandisland => ['http://grandisland.craigslist.org/'],
|
268
|
+
:lincoln => ['http://lincoln.craigslist.org/'],
|
269
|
+
:omaha => ['http://omaha.craigslist.org/'],
|
270
|
+
:siouxcity => ['http://siouxcity.craigslist.org/'],
|
271
|
+
# Nevada =
|
272
|
+
:lasvegas => ['http://lasvegas.craigslist.org/'],
|
273
|
+
:reno => ['http://reno.craigslist.org/'],
|
274
|
+
# N hampshire =
|
275
|
+
:nh => ['http://nh.craigslist.org/'],
|
276
|
+
# New jersey =
|
277
|
+
:cnj => ['http://cnj.craigslist.org/'],
|
278
|
+
:jerseyshore => ['http://jerseyshore.craigslist.org/'],
|
279
|
+
:newjersey => ['http://newjersey.craigslist.org/'],
|
280
|
+
:southjersey => ['http://southjersey.craigslist.org/'],
|
281
|
+
# New mexico =
|
282
|
+
:albuquerque => ['http://albuquerque.craigslist.org/'],
|
283
|
+
:farmington => ['http://farmington.craigslist.org/'],
|
284
|
+
:lascruces => ['http://lascruces.craigslist.org/'],
|
285
|
+
:roswell => ['http://roswell.craigslist.org/'],
|
286
|
+
:santafe => ['http://santafe.craigslist.org/'],
|
287
|
+
# New york =
|
288
|
+
:albany => ['http://albany.craigslist.org/'],
|
289
|
+
:binghamton => ['http://binghamton.craigslist.org/'],
|
290
|
+
:buffalo => ['http://buffalo.craigslist.org/'],
|
291
|
+
:catskills => ['http://catskills.craigslist.org/'],
|
292
|
+
:chautauqua => ['http://chautauqua.craigslist.org/'],
|
293
|
+
:elmira => ['http://elmira.craigslist.org/'],
|
294
|
+
:hudsonvalley => ['http://hudsonvalley.craigslist.org/'],
|
295
|
+
:ithaca => ['http://ithaca.craigslist.org/'],
|
296
|
+
:longisland => ['http://longisland.craigslist.org/'],
|
297
|
+
:newyork => ['http://newyork.craigslist.org/'],
|
298
|
+
:plattsburgh => ['http://plattsburgh.craigslist.org/'],
|
299
|
+
:rochester => ['http://rochester.craigslist.org/'],
|
300
|
+
:syracuse => ['http://syracuse.craigslist.org/'],
|
301
|
+
:utica => ['http://utica.craigslist.org/'],
|
302
|
+
:watertown => ['http://watertown.craigslist.org/'],
|
303
|
+
# N carolina =
|
304
|
+
:asheville => ['http://asheville.craigslist.org/'],
|
305
|
+
:boone => ['http://boone.craigslist.org/'],
|
306
|
+
:charlotte => ['http://charlotte.craigslist.org/'],
|
307
|
+
:eastnc => ['http://eastnc.craigslist.org/'],
|
308
|
+
:fayetteville => ['http://fayetteville.craigslist.org/'],
|
309
|
+
:greensboro => ['http://greensboro.craigslist.org/'],
|
310
|
+
:hickory => ['http://hickory.craigslist.org/'],
|
311
|
+
:outerbanks => ['http://outerbanks.craigslist.org/'],
|
312
|
+
:raleigh => ['http://raleigh.craigslist.org/'],
|
313
|
+
:wilmington => ['http://wilmington.craigslist.org/'],
|
314
|
+
:winstonsalem => ['http://winstonsalem.craigslist.org/'],
|
315
|
+
# North dakota =
|
316
|
+
:fargo => ['http://fargo.craigslist.org/'],
|
317
|
+
:nd => ['http://nd.craigslist.org/'],
|
318
|
+
# Ohio =
|
319
|
+
:akroncanton => ['http://akroncanton.craigslist.org/'],
|
320
|
+
:athensohio => ['http://athensohio.craigslist.org/'],
|
321
|
+
:cincinnati => ['http://cincinnati.craigslist.org/'],
|
322
|
+
:cleveland => ['http://cleveland.craigslist.org/'],
|
323
|
+
:columbus => ['http://columbus.craigslist.org/'],
|
324
|
+
:dayton => ['http://dayton.craigslist.org/'],
|
325
|
+
:huntington => ['http://huntington.craigslist.org/'],
|
326
|
+
:limaohio => ['http://limaohio.craigslist.org/'],
|
327
|
+
:mansfield => ['http://mansfield.craigslist.org/'],
|
328
|
+
:parkersburg => ['http://parkersburg.craigslist.org/'],
|
329
|
+
:sandusky => ['http://sandusky.craigslist.org/'],
|
330
|
+
:toledo => ['http://toledo.craigslist.org/'],
|
331
|
+
:wheeling => ['http://wheeling.craigslist.org/'],
|
332
|
+
:youngstown => ['http://youngstown.craigslist.org/'],
|
333
|
+
# Oklahoma =
|
334
|
+
:fortsmith => ['http://fortsmith.craigslist.org/'],
|
335
|
+
:lawton => ['http://lawton.craigslist.org/'],
|
336
|
+
:oklahomacity => ['http://oklahomacity.craigslist.org/'],
|
337
|
+
:stillwater => ['http://stillwater.craigslist.org/'],
|
338
|
+
:tulsa => ['http://tulsa.craigslist.org/'],
|
339
|
+
# Oregon =
|
340
|
+
:bend => ['http://bend.craigslist.org/'],
|
341
|
+
:corvallis => ['http://corvallis.craigslist.org/'],
|
342
|
+
:eastoregon => ['http://eastoregon.craigslist.org/'],
|
343
|
+
:eugene => ['http://eugene.craigslist.org/'],
|
344
|
+
:medford => ['http://medford.craigslist.org/'],
|
345
|
+
:oregoncoast => ['http://oregoncoast.craigslist.org/'],
|
346
|
+
:portland => ['http://portland.craigslist.org/'],
|
347
|
+
:roseburg => ['http://roseburg.craigslist.org/'],
|
348
|
+
:salem => ['http://salem.craigslist.org/'],
|
349
|
+
# Pennsylvania =
|
350
|
+
:altoona => ['http://altoona.craigslist.org/'],
|
351
|
+
:erie => ['http://erie.craigslist.org/'],
|
352
|
+
:harrisburg => ['http://harrisburg.craigslist.org/'],
|
353
|
+
:lancaster => ['http://lancaster.craigslist.org/'],
|
354
|
+
:allentown => ['http://allentown.craigslist.org/'],
|
355
|
+
:philadelphia => ['http://philadelphia.craigslist.org/'],
|
356
|
+
:pittsburgh => ['http://pittsburgh.craigslist.org/'],
|
357
|
+
:poconos => ['http://poconos.craigslist.org/'],
|
358
|
+
:reading => ['http://reading.craigslist.org/'],
|
359
|
+
:scranton => ['http://scranton.craigslist.org/'],
|
360
|
+
:pennstate => ['http://pennstate.craigslist.org/'],
|
361
|
+
:williamsport => ['http://williamsport.craigslist.org/'],
|
362
|
+
:york => ['http://york.craigslist.org/'],
|
363
|
+
# Rhode island =
|
364
|
+
:providence => ['http://providence.craigslist.org/'],
|
365
|
+
# S carolina =
|
366
|
+
:charleston => ['http://charleston.craigslist.org/'],
|
367
|
+
:columbia => ['http://columbia.craigslist.org/'],
|
368
|
+
:florencesc => ['http://florencesc.craigslist.org/'],
|
369
|
+
:greenville => ['http://greenville.craigslist.org/'],
|
370
|
+
:hiltonhead => ['http://hiltonhead.craigslist.org/'],
|
371
|
+
:myrtlebeach => ['http://myrtlebeach.craigslist.org/'],
|
372
|
+
# South dakota =
|
373
|
+
:sd => ['http://sd.craigslist.org/'],
|
374
|
+
# Tennessee =
|
375
|
+
:chattanooga => ['http://chattanooga.craigslist.org/'],
|
376
|
+
:clarksville => ['http://clarksville.craigslist.org/'],
|
377
|
+
:jacksontn => ['http://jacksontn.craigslist.org/'],
|
378
|
+
:knoxville => ['http://knoxville.craigslist.org/'],
|
379
|
+
:memphis => ['http://memphis.craigslist.org/'],
|
380
|
+
:nashville => ['http://nashville.craigslist.org/'],
|
381
|
+
:tricities => ['http://tricities.craigslist.org/'],
|
382
|
+
# Texas =
|
383
|
+
:abilene => ['http://abilene.craigslist.org/'],
|
384
|
+
:amarillo => ['http://amarillo.craigslist.org/'],
|
385
|
+
:austin => ['http://austin.craigslist.org/'],
|
386
|
+
:beaumont => ['http://beaumont.craigslist.org/'],
|
387
|
+
:brownsville => ['http://brownsville.craigslist.org/'],
|
388
|
+
:collegestation => ['http://collegestation.craigslist.org/'],
|
389
|
+
:corpuschristi => ['http://corpuschristi.craigslist.org/'],
|
390
|
+
:dallas => ['http://dallas.craigslist.org/'],
|
391
|
+
:elpaso => ['http://elpaso.craigslist.org/'],
|
392
|
+
:galveston => ['http://galveston.craigslist.org/'],
|
393
|
+
:houston => ['http://houston.craigslist.org/'],
|
394
|
+
:killeen => ['http://killeen.craigslist.org/'],
|
395
|
+
:laredo => ['http://laredo.craigslist.org/'],
|
396
|
+
:lubbock => ['http://lubbock.craigslist.org/'],
|
397
|
+
:mcallen => ['http://mcallen.craigslist.org/'],
|
398
|
+
:odessa => ['http://odessa.craigslist.org/'],
|
399
|
+
:sanantonio => ['http://sanantonio.craigslist.org/'],
|
400
|
+
:sanmarcos => ['http://sanmarcos.craigslist.org/'],
|
401
|
+
:texarkana => ['http://texarkana.craigslist.org/'],
|
402
|
+
:easttexas => ['http://easttexas.craigslist.org/'],
|
403
|
+
:victoriatx => ['http://victoriatx.craigslist.org/'],
|
404
|
+
:waco => ['http://waco.craigslist.org/'],
|
405
|
+
:wichitafalls => ['http://wichitafalls.craigslist.org/'],
|
406
|
+
# Utah =
|
407
|
+
:logan => ['http://logan.craigslist.org/'],
|
408
|
+
:ogden => ['http://ogden.craigslist.org/'],
|
409
|
+
:provo => ['http://provo.craigslist.org/'],
|
410
|
+
:saltlakecity => ['http://saltlakecity.craigslist.org/'],
|
411
|
+
:stgeorge => ['http://stgeorge.craigslist.org/'],
|
412
|
+
# Vermont =
|
413
|
+
:burlington => ['http://burlington.craigslist.org/'],
|
414
|
+
# Virginia =
|
415
|
+
:blacksburg => ['http://blacksburg.craigslist.org/'],
|
416
|
+
:charlottesville => ['http://charlottesville.craigslist.org/'],
|
417
|
+
:danville => ['http://danville.craigslist.org/'],
|
418
|
+
:easternshore => ['http://easternshore.craigslist.org/'],
|
419
|
+
:fredericksburg => ['http://fredericksburg.craigslist.org/'],
|
420
|
+
:norfolk => ['http://norfolk.craigslist.org/'],
|
421
|
+
:harrisonburg => ['http://harrisonburg.craigslist.org/'],
|
422
|
+
:lynchburg => ['http://lynchburg.craigslist.org/'],
|
423
|
+
:richmond => ['http://richmond.craigslist.org/'],
|
424
|
+
:roanoke => ['http://roanoke.craigslist.org/'],
|
425
|
+
# Washington =
|
426
|
+
:bellingham => ['http://bellingham.craigslist.org/'],
|
427
|
+
:kpr => ['http://kpr.craigslist.org/'],
|
428
|
+
:olympic => ['http://olympic.craigslist.org/'],
|
429
|
+
:pullman => ['http://pullman.craigslist.org/'],
|
430
|
+
:seattle => ['http://seattle.craigslist.org/'],
|
431
|
+
:skagit => ['http://skagit.craigslist.org/'],
|
432
|
+
:spokane => ['http://spokane.craigslist.org/'],
|
433
|
+
:wenatchee => ['http://wenatchee.craigslist.org/'],
|
434
|
+
:yakima => ['http://yakima.craigslist.org/'],
|
435
|
+
# West virginia =
|
436
|
+
:charlestonwv => ['http://charlestonwv.craigslist.org/'],
|
437
|
+
:huntington => ['http://huntington.craigslist.org/'],
|
438
|
+
:martinsburg => ['http://martinsburg.craigslist.org/'],
|
439
|
+
:morgantown => ['http://morgantown.craigslist.org/'],
|
440
|
+
:parkersburg => ['http://parkersburg.craigslist.org/'],
|
441
|
+
:wv => ['http://wv.craigslist.org/'],
|
442
|
+
:wheeling => ['http://wheeling.craigslist.org/'],
|
443
|
+
# Wisconsin =
|
444
|
+
:appleton => ['http://appleton.craigslist.org/'],
|
445
|
+
:duluth => ['http://duluth.craigslist.org/'],
|
446
|
+
:eauclaire => ['http://eauclaire.craigslist.org/'],
|
447
|
+
:greenbay => ['http://greenbay.craigslist.org/'],
|
448
|
+
:janesville => ['http://janesville.craigslist.org/'],
|
449
|
+
:racine => ['http://racine.craigslist.org/'],
|
450
|
+
:lacrosse => ['http://lacrosse.craigslist.org/'],
|
451
|
+
:madison => ['http://madison.craigslist.org/'],
|
452
|
+
:milwaukee => ['http://milwaukee.craigslist.org/'],
|
453
|
+
:sheboygan => ['http://sheboygan.craigslist.org/'],
|
454
|
+
:wausau => ['http://wausau.craigslist.org/']
|
455
|
+
}
|
456
|
+
|
457
|
+
CATEGORIES = {
|
458
|
+
:community => 'ccc',
|
459
|
+
:event => 'eee',
|
460
|
+
:all_for_sale_or_wanted => 'sss',
|
461
|
+
:art_and_crafts => 'art',
|
462
|
+
:auto_parts => 'pts',
|
463
|
+
:baby_and_kid_stuff => 'bab',
|
464
|
+
:barter => 'bar',
|
465
|
+
:bicycles => 'bik',
|
466
|
+
:boats => 'boa',
|
467
|
+
:books => 'bks',
|
468
|
+
:business => 'bfs',
|
469
|
+
:cars_and_trucks => 'cta',
|
470
|
+
:media => 'emd',
|
471
|
+
:clothing => 'clo',
|
472
|
+
:collectibles => 'clt',
|
473
|
+
:computers_and_tech => 'sys',
|
474
|
+
:electronics => 'ele',
|
475
|
+
:farm_and_garden => 'grd',
|
476
|
+
:free_stuff => 'zip',
|
477
|
+
:furniture => 'fua',
|
478
|
+
:games_and_toys => 'tag',
|
479
|
+
:garage_sales => 'gms',
|
480
|
+
:general => 'for',
|
481
|
+
:household => 'hsh',
|
482
|
+
:items_wanted => 'wan',
|
483
|
+
:jewelry => 'jwl',
|
484
|
+
:materials => 'mat',
|
485
|
+
:motorcycles => 'mcy',
|
486
|
+
:musical_instruments => 'msg',
|
487
|
+
:photo_and_video => 'pho',
|
488
|
+
:recreational_vehicles => 'rvs',
|
489
|
+
:sporting_goods => 'spo',
|
490
|
+
:tickets => 'tix',
|
491
|
+
:tools => 'tls',
|
492
|
+
:gigs => 'ggg',
|
493
|
+
:housing => 'hhh',
|
494
|
+
:jobs => 'jjj',
|
495
|
+
:personals => 'ppp',
|
496
|
+
:resume => 'res',
|
497
|
+
:services_offered => 'bbb'
|
498
|
+
}
|
499
|
+
|
500
|
+
# :startdoc:
|
501
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Craigler
|
4
|
+
class Search
|
5
|
+
include ERB::Util
|
6
|
+
|
7
|
+
attr_reader :search_term, :categories, :locations, :page_limit
|
8
|
+
|
9
|
+
# Creates a wrapper object for a craigslist search
|
10
|
+
#
|
11
|
+
# === Options
|
12
|
+
# [:in]
|
13
|
+
# Specifies the location(s) to search in. Defaults to <tt>:anywhere</tt>.
|
14
|
+
# [:only]
|
15
|
+
# Specifies the category or categories to search in. Defaults to <tt>:all_for_sale_or_wanted</tt>
|
16
|
+
# [:page_limit]
|
17
|
+
# Maximum number of pages to fetch results from. Defaults to <tt>4</tt>.
|
18
|
+
# <b>Note:</b> A location may, and often does, have more than one searchable
|
19
|
+
# url assciated with it, e.g., {California}[http://geo.craigslist.org/iso/us/ca]. Because
|
20
|
+
# <tt>:page_limit</tt> is applied seperately to each url within the location, searching <tt>:in => :california</tt>
|
21
|
+
# with a <tt>:page_limit => 4</tt> could potentially make up to 100 page requests.
|
22
|
+
def initialize(search_term, options = {})
|
23
|
+
raise InvalidSearchTerm if search_term.nil? || search_term == ''
|
24
|
+
|
25
|
+
options = {:in => :anywhere, :only => :all_for_sale_or_wanted, :page_limit => 4}.merge(options)
|
26
|
+
options[:in] = LOCATIONS.keys if options[:in] == :anywhere
|
27
|
+
@locations = (options[:in].is_a?(Array) ? options[:in] : [options[:in]]).collect(&:to_sym)
|
28
|
+
@categories = (options[:only].is_a?(Array) ? options[:only] : [options[:only]]).collect(&:to_sym)
|
29
|
+
@page_limit = options[:page_limit]
|
30
|
+
@search_term = search_term
|
31
|
+
@results = nil
|
32
|
+
|
33
|
+
_validate_locations()
|
34
|
+
_validate_categories()
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the results of the search. If this is the first time
|
38
|
+
# calling #results then they will be fetched over the internet and cached in the search object.
|
39
|
+
#
|
40
|
+
# === Options
|
41
|
+
# [:refresh]
|
42
|
+
# Set to <tt>true</tt> to force an update across the internet.
|
43
|
+
def results(options = {})
|
44
|
+
options = { :refresh => false }.merge(options)
|
45
|
+
return @results unless @results.nil? || options[:refresh]
|
46
|
+
|
47
|
+
@results = []
|
48
|
+
last_page = @page_limit - 1 # pages start at 0
|
49
|
+
|
50
|
+
_for_each_locations_search_url() do |location, url|
|
51
|
+
(0..last_page).each do |page|
|
52
|
+
results = _extract_items_from_url(location, "#{url}&s=#{page*25}")
|
53
|
+
@results.push(*results)
|
54
|
+
break if results.size < RESULTS_PER_PAGE
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
results
|
59
|
+
end
|
60
|
+
|
61
|
+
protected
|
62
|
+
def _validate_locations # :nodoc:
|
63
|
+
@locations.each() do |location|
|
64
|
+
raise InvalidLocation.new(":anywhere not expected as part of an array") if location == :anywhere
|
65
|
+
raise InvalidLocation.new(":#{location} is not a valid location") unless LOCATIONS.key?(location)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def _validate_categories # :nodoc:
|
70
|
+
@categories.each() do |category|
|
71
|
+
raise InvalidCategory unless CATEGORIES.key?(category)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def _for_each_locations_search_url # :nodoc:
|
76
|
+
@locations.each do |location|
|
77
|
+
LOCATIONS[location].each do |url|
|
78
|
+
@categories.each do |category|
|
79
|
+
yield(location, "#{url}search/#{CATEGORIES[category]}?query=#{url_encode(@search_term)}&format=rss")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def _extract_items_from_url(location, url) # :nodoc:
|
86
|
+
(Hpricot(open(url))/'item').collect { |item| {
|
87
|
+
:url => item['rdf:about'],
|
88
|
+
:title => (item%'title').inner_text,
|
89
|
+
:location => location.to_s,
|
90
|
+
:published_at => Time.parse((item%'dc:date').inner_text)
|
91
|
+
}}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CraiglerSearchTest < Test::Unit::TestCase
|
4
|
+
context "creating a search" do
|
5
|
+
should "require a valid category" do
|
6
|
+
assert_raises(Craigler::InvalidCategory) do
|
7
|
+
Craigler::Search.new('Yamaha Radian', :only => :invalid)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
should "require a search term" do
|
12
|
+
assert_raises(Craigler::InvalidSearchTerm) do
|
13
|
+
Craigler::Search.new(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
assert_raises(ArgumentError) do
|
17
|
+
Craigler::Search.new()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not require a location" do
|
22
|
+
assert_nothing_raised() do
|
23
|
+
Craigler::Search.new('Yamaha Roadstar Warrior', :only => :motorcycles)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
should "not require a category" do
|
28
|
+
assert_nothing_raised() do
|
29
|
+
Craigler::Search.new('Honda Shadow', :in => :utah)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
should "use a default category of :all_for_sale_or_wanted" do
|
34
|
+
search = Craigler::Search.new('Buell', :in => :utah)
|
35
|
+
assert(search.categories == [:all_for_sale_or_wanted],
|
36
|
+
"category was [:#{search.categories.join(", :")}] but should have been [:all_for_sale_or_wanted]")
|
37
|
+
end
|
38
|
+
|
39
|
+
should "require that the location is valid" do
|
40
|
+
assert_raises(Craigler::InvalidLocation) do
|
41
|
+
Craigler::Search.new('Honda Nighthawk', :in => :invalid)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
should "accept multiple locations" do
|
46
|
+
assert_nothing_raised() do
|
47
|
+
Craigler::Search.new('Suzuki Boulevard M50', :in => [:utah, :nevada])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
should "allow us to limit the number of pages searched" do
|
52
|
+
one_page_count = Craigler::Search.new('Honda', :in => :utah, :page_limit => 1).results.size
|
53
|
+
two_page_count = Craigler::Search.new('Honda', :in => :utah, :page_limit => 2).results.size
|
54
|
+
assert(one_page_count < two_page_count, "#{one_page_count} is not less than #{two_page_count}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "fetching search results" do
|
59
|
+
setup do
|
60
|
+
@search = Craigler::Search.new('Honda', :in => :utah, :only => :motorcycles, :page_limit => 1)
|
61
|
+
end
|
62
|
+
|
63
|
+
should "return an array of hashes" do
|
64
|
+
results = @search.results()
|
65
|
+
assert(results.is_a?(Array), "Array exptected but was #{results.class}")
|
66
|
+
assert(results.size > 0, "No results were returned")
|
67
|
+
assert(results.inject(true) {|t,r| t && r.is_a?(Hash)})
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CraiglerTest < Test::Unit::TestCase
|
4
|
+
context "Search interface" do
|
5
|
+
should "respond to search" do
|
6
|
+
assert_respond_to(Craigler, :search)
|
7
|
+
end
|
8
|
+
|
9
|
+
should "yield results to a block if given" do
|
10
|
+
yielded = false
|
11
|
+
Craigler::search(:motorcycles, :in => :utah, :for => 'Yamaha', :page_limit => 1) do
|
12
|
+
yielded = true; break;
|
13
|
+
end
|
14
|
+
|
15
|
+
assert(yielded, "results were never yielded to the block")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Find interface" do
|
20
|
+
should "respond to find" do
|
21
|
+
assert_respond_to(Craigler, :find)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "yield results to a block if given" do
|
25
|
+
yielded = false
|
26
|
+
Craigler::find('Yamaha', :in => :utah, :only => :motorcycles, :page_limit => 1) do
|
27
|
+
yielded = true; break;
|
28
|
+
end
|
29
|
+
|
30
|
+
assert(yielded, "results were never yielded to the block")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
require 'craigler'
|
9
|
+
|
10
|
+
module Craigler
|
11
|
+
class Search
|
12
|
+
def open(*args)
|
13
|
+
@@results_page ||= Kernel::open("http://saltlakecity.craigslist.org/search/sss?query=Honda&format=rss&s=0").read()
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: craigler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Devin Christensen
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-05 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 33
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 10
|
33
|
+
- 3
|
34
|
+
version: 2.10.3
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description:
|
38
|
+
email: quixoten@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- LICENSE
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- .document
|
48
|
+
- .gitignore
|
49
|
+
- LICENSE
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- VERSION.yml
|
53
|
+
- craigler.gemspec
|
54
|
+
- lib/craigler.rb
|
55
|
+
- lib/craigler/constants.rb
|
56
|
+
- lib/craigler/search.rb
|
57
|
+
- test/craigler_search_test.rb
|
58
|
+
- test/craigler_test.rb
|
59
|
+
- test/test_helper.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://github.com/threetrieslater/craigler
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --charset=UTF-8
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.3.7
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Search API for craigslist
|
94
|
+
test_files:
|
95
|
+
- test/craigler_search_test.rb
|
96
|
+
- test/craigler_test.rb
|
97
|
+
- test/test_helper.rb
|