sgeoip 0.0.6
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/sgeoip.rb +21 -0
- metadata +62 -0
data/lib/sgeoip.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "geoip/version"
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module Sgeoip
|
6
|
+
def self.scrape(ip)
|
7
|
+
url = "http://www.geoiptool.com/en/?#{ip}"
|
8
|
+
doc = Nokogiri::HTML(open(url))
|
9
|
+
geoip = { "host" => doc.at_css(".tbl_style tr:nth-child(1) td.arial_bold").text,
|
10
|
+
"country" => doc.at_css(".tbl_style tr:nth-child(3) td.arial_bold").text,
|
11
|
+
"country_code" => doc.at_css(".tbl_style tr:nth-child(4) td.arial_bold").text,
|
12
|
+
"region" => doc.at_css(".tbl_style tr:nth-child(5) td.arial_bold").text,
|
13
|
+
"city" => doc.at_css(".tbl_style tr:nth-child(6) td.arial_bold").text,
|
14
|
+
"zip" => doc.at_css(".tbl_style tr:nth-child(7) td.arial_bold").text
|
15
|
+
}
|
16
|
+
if geoip[:host].nil?
|
17
|
+
geoip[:error] = "Results Not Found"
|
18
|
+
end
|
19
|
+
geoip
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sgeoip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Travis Berry
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Scrape http://www.geoiptool.com/ for ip information
|
31
|
+
email:
|
32
|
+
- contact@travisberry.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- ./lib/sgeoip.rb
|
38
|
+
homepage: ''
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- ./lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.23
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Scrape http://www.geoiptool.com/
|
62
|
+
test_files: []
|