Module: YahooSports
- Defined in:
- lib/yahoo_sports.rb,
lib/yahoo_sports/mlb.rb,
lib/yahoo_sports/nba.rb,
lib/yahoo_sports/nfl.rb,
lib/yahoo_sports/nhl.rb,
lib/yahoo_sports/base.rb
Defined Under Namespace
Classes: Base, MLB, NBA, NFL, NHL
Class Method Summary collapse
-
.fetchurl(url) ⇒ String
Fetches the given URL and returns the body.
-
.strip_tags(html) ⇒ String
Strip HTML tags from the given string.
Class Method Details
.fetchurl(url) ⇒ String
Fetches the given URL and returns the body
22 23 24 25 |
# File 'lib/yahoo_sports/base.rb', line 22 def self.fetchurl(url) # puts "FETCHING: '#{url}'" return Net::HTTP.get_response(URI.parse(URI.escape(url))).body end |
.strip_tags(html) ⇒ String
Strip HTML tags from the given string. Also performs some common entity substitutions.
List of entity codes:
-
-
&
-
"
-
<
-
>
-
&ellip;
-
'
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/yahoo_sports/base.rb', line 41 def self.(html) HTMLEntities.new.decode( html.gsub(/<.+?>/,''). gsub(/ /,' '). gsub(/&/,'&'). gsub(/"/,'"'). gsub(/</,'<'). gsub(/>/,'>'). gsub(/&ellip;/,'...'). gsub(/'/, "'"). gsub(/<br *\/>/m, '') ).strip end |