beeradvocate 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f1c6d4b4772fb31c2f0de4c74a4401e08359ac4
4
- data.tar.gz: b9d5050a81d57a678f82b22e29c6b3d383d11599
3
+ metadata.gz: 202edfe8ff06b907a1ede18c66e0b968f7edf8db
4
+ data.tar.gz: 8eceab449dd7654a5e68f9f1420be37b675016ee
5
5
  SHA512:
6
- metadata.gz: 7ab3ab5217a00220baf56c76bfd57386089fabd52c9cf285f9e19f97457f658548c3bd9818a7b1075ecc66637f47d6bb360671e5391be176d98dc22203139e9c
7
- data.tar.gz: e960542038a1b7efeb1c1f3dfc1c90e33bec89ad8e2e915bed65356322a889748905ab1b5f1941076ff3acf5634c498f3d27023bd31876c3db2ca1579acf752c
6
+ metadata.gz: b40a9d2c5160968d16ff3bf349548e40f4866d3b53bfd4e221c291f37ab2768686e22fc9b67b1d243ebcc4a2ab7e9e5d47b28b57ba7d57be055c83013f3bbb44
7
+ data.tar.gz: 4be5c6d7ce4135bf744602cda53dbe3fcc6a75e1689fe366bd548738aa452ae889397bc48515a66c2b10b274d19d2cdef1ad53c302030dce2495b20c963c7d4f
data/lib/beer_advocate.rb CHANGED
@@ -1,31 +1,23 @@
1
1
  require 'nokogiri'
2
- require 'mechanize'
3
2
  require 'open-uri'
3
+ require 'uri'
4
4
 
5
5
  require 'beer_advocate/version'
6
6
 
7
- ## A handful of utilities for making beer signs based on Beer Advocate data.
7
+ ## Quickly-coded utilities for scraping BeerAdvocate.com for beer information.
8
8
  module BeerAdvocate
9
9
  class << self
10
- ## Given a beer name, return the URL for the top Google search result for
11
- ## `site:beeradvocate.com beer name`.
12
- def get_url(beer_name)
13
- agent = Mechanize.new
14
- page = agent.get('http://www.google.com')
15
- form = page.form('f')
16
- form.q = "site:beeradvocate.com #{beer_name}"
17
10
 
18
- results = agent.submit(form, form.buttons.first)
11
+ ## Given a beer name, return the URL for the top Beer Advocate beer
12
+ ## search result.
13
+ def get_url(beer_name)
14
+ page = Nokogiri::HTML(open(
15
+ "http://www.beeradvocate.com/search/?qt=beer&q=" +
16
+ URI.escape(beer_name)
17
+ ))
19
18
 
20
- urls = []
21
- results.links.each do |link|
22
- if link.href.to_s =~/url.q/
23
- str=link.href.to_s
24
- strList=str.split(%r{=|&})
25
- urls << strList[1]
26
- end
27
- end
28
- urls.select {|url| url.match(/beeradvocate.com/)}.first
19
+ "http://www.beeradvocate.com" +
20
+ page.css('ul li a').first.attributes['href'].text
29
21
  end
30
22
 
31
23
 
@@ -62,6 +54,7 @@ module BeerAdvocate
62
54
  brewery: beer_brewery
63
55
  }
64
56
  end
57
+
65
58
  end
66
59
  end
67
60
 
@@ -1,5 +1,5 @@
1
1
  module BeerAdvocate
2
- VERSION = '0.0.1'
3
- VERSION_DATE = '2015-07-01'
2
+ VERSION = '0.0.2'
3
+ VERSION_DATE = '2015-07-02'
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beeradvocate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Gamache
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
- - !ruby/object:Gem::Dependency
28
- name: mechanize
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.7'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.7'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -103,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
89
  version: '0'
104
90
  requirements: []
105
91
  rubyforge_project:
106
- rubygems_version: 2.2.2
92
+ rubygems_version: 2.4.6
107
93
  signing_key:
108
94
  specification_version: 4
109
95
  summary: Fragile, minimal utilities to scrape Beer Advocate