google_company_search 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2dfcfcf0aa1487011ecffa7ae535d0ec9f93266
4
+ data.tar.gz: 0f68de0063e02b13df2b7f7840814f2469bca0fa
5
+ SHA512:
6
+ metadata.gz: c60abc219545ae6ecd03f5632eaa5db2f7c2f57fc21d413fe8b76fb4651b567ae5db0990a8d6905e16150b951350cc365fc389ae681a9747999370bebe82a123
7
+ data.tar.gz: b5be205ca0e0a4ccf0330e41993c0ae8776baed9372248087c469937cf7a4912401906f3ecda9038654ea5bbb97ea681965305384370f24fb321d4cdf29aa296
@@ -0,0 +1,50 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
16
+ *.rbc
17
+ /.config
18
+ /coverage/
19
+ /InstalledFiles
20
+ /pkg/
21
+ /spec/reports/
22
+ /spec/examples.txt
23
+ /test/tmp/
24
+ /test/version_tmp/
25
+ /tmp/
26
+
27
+ ## Specific to RubyMotion:
28
+ .dat*
29
+ .repl_history
30
+ build/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in google_company_search.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Brian Schwartz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 TODO: Write your name
2
+
3
+ MIT License
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.
@@ -0,0 +1,36 @@
1
+ # GoogleCompanySearch
2
+
3
+ A google scrape tool to provide a URL by searching for a company name
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'google_company_search'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install google_company_search
20
+
21
+ ## Usage
22
+ require 'google_company_search'
23
+
24
+ ```ruby
25
+ GoogleCompanySearch.search("Boeing") #returns "http://www.boeing.com/"
26
+ GoogleCompanySearch.search("My Company Name Here", "St. Louis, Missouri")
27
+ ```
28
+ ## Todo: The blacklist could be made into a YML file. Or something else outside code.
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/creativereason/google_company_search/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'google_company_search/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "google_company_search"
8
+ spec.version = GoogleCompanySearch::VERSION
9
+ spec.authors = ["Brian Schwartz"]
10
+ spec.email = ["bschwartz@creativereason.com"]
11
+ spec.summary = %q{A google scrape tool to provide a URL by searching for a company name}
12
+ spec.description = %q{Includes a blacklist of URLs to filter out business news sites, aggregators (like Manta, Bloomberg, Hoover's) social sites(facebook, twitter, linked)}
13
+ spec.homepage = "https://github.com/creativereason/google_company_search"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "mechanize"
24
+ end
@@ -0,0 +1,42 @@
1
+ require "google_company_search/version"
2
+ require 'mechanize'
3
+ require 'uri'
4
+
5
+ class GoogleCompanySearch
6
+ def self.search(name, location = nil)
7
+ agent = Mechanize.new
8
+ page = agent.get('http://www.google.com/')
9
+ google_form = page.form('f')
10
+ google_form.q =
11
+ if location.nil?
12
+ name
13
+ else
14
+ "#{name} #{location}"
15
+ end
16
+ page = agent.submit(google_form, google_form.buttons.first)
17
+ valid_url = nil
18
+ page.links.each do |link|
19
+ if link.href.to_s =~/url.q/
20
+ str=link.href.to_s
21
+ strList=str.split(%r{=|&})
22
+ url=strList[1]
23
+ if is_valid_link(url)
24
+ valid_url = url
25
+ break
26
+ end
27
+ end
28
+ end
29
+ valid_url
30
+ end
31
+
32
+ private
33
+ def is_valid_link(link)
34
+ blacklist = ["wikipedia.org", "manta.com", "hoovers.com", "google.com", "techcrunch.com", "bbb.org", "bloomberg.com", "yellowpages.org", "yp.com", "yellowpages.com", "fda.gov", "yelp.com", "findlaw.com", "cnbc.com", "urbandictionary.com", "webcache.googleusercontent.com", "linkedin.com", "twitter.com", "facebook.com", "yellowpagesgoesgreen.com", "mapquest.com", "whereorg.com", "macraesbluebook.com", "bizjournals.com", "amfibi.directory"]
35
+ return false if link.match(/^(http|https):\/\//) == nil
36
+ uri = URI(link)
37
+ uri = uri.host.sub("www.", "")
38
+ puts uri
39
+ return false if blacklist.include?(uri)
40
+ true
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ class GoogleCompanySearch
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google_company_search
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Schwartz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mechanize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Includes a blacklist of URLs to filter out business news sites, aggregators
56
+ (like Manta, Bloomberg, Hoover's) social sites(facebook, twitter, linked)
57
+ email:
58
+ - bschwartz@creativereason.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - google_company_search.gemspec
70
+ - lib/google_company_search.rb
71
+ - lib/google_company_search/version.rb
72
+ homepage: https://github.com/creativereason/google_company_search
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: A google scrape tool to provide a URL by searching for a company name
96
+ test_files: []