whos_using_what 0.0.3 → 0.0.4
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.
- data/lib/whos_using_what/search_client.rb +41 -2
- data/lib/whos_using_what.rb +1 -1
- metadata +1 -1
@@ -12,6 +12,9 @@ class SearchClient
|
|
12
12
|
|
13
13
|
@positiveMatchUrlPatterns = Array.new.push("http")
|
14
14
|
|
15
|
+
@technologiesToSearchFor = Array.new.push("ruby").push("java").push("javascript").push("python").push("c++").push("c#")
|
16
|
+
|
17
|
+
@jobPageTokens = Array.new.push("job", "hiring", "career")
|
15
18
|
|
16
19
|
@results = Hash.new
|
17
20
|
|
@@ -45,20 +48,56 @@ class SearchClient
|
|
45
48
|
if (add)
|
46
49
|
acceptedUrls.push(url)
|
47
50
|
end
|
51
|
+
end
|
52
|
+
acceptedUrls
|
53
|
+
end
|
48
54
|
|
49
55
|
|
56
|
+
def arraySearch(array, rawHtml)
|
57
|
+
|
58
|
+
rawHtml = rawHtml.downcase
|
59
|
+
array.each do |token|
|
60
|
+
if (rawHtml.index(token) != nil)
|
61
|
+
return true
|
62
|
+
end
|
50
63
|
end
|
64
|
+
return false
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def determineIfUsesTechnology(technology, rawHtml)
|
69
|
+
|
70
|
+
isJobPage = arraySearch(@jobPageTokens, rawHtml)
|
71
|
+
|
72
|
+
return isJobPage
|
51
73
|
|
52
74
|
end
|
53
75
|
|
76
|
+
|
54
77
|
def search(site, query)
|
55
78
|
|
56
79
|
url = "https://www.google.com/search?hl=en&as_q=" << query << "&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=" << site << "&as_occt=any&safe=off&tbs=&as_filetype=&as_rights="
|
57
80
|
|
58
81
|
rawHtml = RestClient.get(url)
|
59
82
|
|
60
|
-
extractUrls(rawHtml, site)
|
83
|
+
urls = extractUrls(rawHtml, site)
|
84
|
+
|
85
|
+
isMatch = false
|
86
|
+
|
87
|
+
urls.each do |url|
|
88
|
+
if (determineIfUsesTechnology(query, RestClient.get(url)))
|
89
|
+
isMatch = true
|
90
|
+
break
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if (isMatch)
|
95
|
+
puts site << " uses " << query
|
96
|
+
else
|
97
|
+
puts site << " does not use " << query
|
98
|
+
end
|
61
99
|
|
62
100
|
end
|
63
101
|
|
64
|
-
end
|
102
|
+
end
|
103
|
+
|
data/lib/whos_using_what.rb
CHANGED