gulesider 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/screen_scraper.rb +16 -12
- metadata +3 -3
data/lib/screen_scraper.rb
CHANGED
@@ -30,14 +30,14 @@ class ScreenScraper
|
|
30
30
|
profile_info = vcard.search "div.profile-info"
|
31
31
|
|
32
32
|
profile_info.search("p").each do |p|
|
33
|
-
name = vcard.search("span.given-name").text + " " + vcard.search("span.family-name").text
|
34
|
-
phone = p.search("span.tel > a").text.strip
|
33
|
+
name = wash(vcard.search("span.given-name").text) + " " + wash(vcard.search("span.family-name").text)
|
34
|
+
phone = wash p.search("span.tel > a").text.strip
|
35
35
|
address = p.search("span.adr")
|
36
|
-
street_name = address.search("span.street-address").text
|
37
|
-
postal_code = address.search("span.postal-code").text
|
38
|
-
city = address.search("span.locality").text
|
39
|
-
lat = address.search("span.latitude").text
|
40
|
-
long = address.search("span.longitude").text
|
36
|
+
street_name = wash address.search("span.street-address").text
|
37
|
+
postal_code = wash address.search("span.postal-code").text
|
38
|
+
city = wash address.search("span.locality").text
|
39
|
+
lat = wash address.search("span.latitude").text
|
40
|
+
long = wash address.search("span.longitude").text
|
41
41
|
|
42
42
|
if phone != ""
|
43
43
|
search_result.push SearchResult.new({
|
@@ -56,6 +56,10 @@ class ScreenScraper
|
|
56
56
|
return search_result
|
57
57
|
end
|
58
58
|
|
59
|
+
def wash str
|
60
|
+
str.gsub(/\r|\n|\t/, "")
|
61
|
+
end
|
62
|
+
|
59
63
|
def scraped_company_data
|
60
64
|
search_result = []
|
61
65
|
list = @result.search "#result-list"
|
@@ -64,11 +68,11 @@ class ScreenScraper
|
|
64
68
|
hits.each do |hit|
|
65
69
|
search_result.push SearchResult.new({
|
66
70
|
:company => true,
|
67
|
-
:name => hit.search("div.header").search("a").text,
|
68
|
-
:phone => hit.search("li.tel:first-child").text,
|
69
|
-
:street_name => hit.search("span.street-address").text,
|
70
|
-
:postal_code => hit.search("span.postal-code").text,
|
71
|
-
:city => hit.search("span.locality").text
|
71
|
+
:name => wash(hit.search("div.header").search("a").text),
|
72
|
+
:phone => wash(hit.search("li.tel:first-child").text),
|
73
|
+
:street_name => wash(hit.search("span.street-address").text),
|
74
|
+
:postal_code => wash(hit.search("span.postal-code").text),
|
75
|
+
:city => wash(hit.search("span.locality").text)
|
72
76
|
})
|
73
77
|
end
|
74
78
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gulesider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-02 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &70211529548380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70211529548380
|
25
25
|
description:
|
26
26
|
email: mail@goeran.no
|
27
27
|
executables:
|