tomtaylor-geo-spider 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/geo-spider/extractors/postcode.rb +12 -4
- data/lib/geo-spider/site.rb +1 -1
- data/lib/geo-spider/version.rb +1 -1
- metadata +1 -1
@@ -11,12 +11,20 @@ module GeoSpider
|
|
11
11
|
REGEXP = /(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])(\s*)[0-9][ABD-HJLNP-UW-Z]{2})/i
|
12
12
|
|
13
13
|
def locations
|
14
|
-
results = @element.
|
14
|
+
results = @element.inner_html.scan(REGEXP)
|
15
15
|
results = results.map(&:first)
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
locations = []
|
18
|
+
|
19
|
+
results.each do |result|
|
20
|
+
begin
|
21
|
+
p = geocoder.locate(result)
|
22
|
+
locations << Location.new(:latitude => p.latitude, :longitude => p.longitude, :title => result)
|
23
|
+
rescue Graticule::Error
|
24
|
+
next
|
25
|
+
end
|
26
|
+
|
27
|
+
return locations
|
20
28
|
end
|
21
29
|
end
|
22
30
|
|
data/lib/geo-spider/site.rb
CHANGED
@@ -28,7 +28,7 @@ module GeoSpider
|
|
28
28
|
seen << url
|
29
29
|
next_links = (page.internal_links - seen - queue) # only add internal links that we've not seen or already have queued.
|
30
30
|
queue.concat(next_links)
|
31
|
-
rescue
|
31
|
+
rescue Timeout::Error => e
|
32
32
|
next
|
33
33
|
end
|
34
34
|
end
|
data/lib/geo-spider/version.rb
CHANGED