-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oliver Denman
committed
Jul 7, 2017
1 parent
dca9f68
commit 60de314
Showing
2 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'scraped' | ||
|
||
class MemberPage < Scraped::HTML | ||
field :party do | ||
noko.at_css('.partyBio').text.tidy | ||
end | ||
|
||
field :phone do | ||
contact_numbers_for('Tel') | ||
end | ||
|
||
field :fax do | ||
contact_numbers_for('Fax') | ||
end | ||
|
||
field :tty do | ||
contact_numbers_for('TTY') | ||
end | ||
|
||
private | ||
|
||
def contact_numbers | ||
noko.xpath('.//span[@class="data-type"]') | ||
end | ||
|
||
def contact_numbers_for(str) | ||
contact_numbers.xpath("text()[contains(.,'#{str}')]").map do |n| | ||
n.text.gsub("#{str}.", '').tidy | ||
end.reject(&:empty?).join(';') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters