Class: PRLS::CLI::Scraper
- Inherits:
-
Object
- Object
- PRLS::CLI::Scraper
- Defined in:
- lib/prls/scraper.rb
Instance Attribute Summary collapse
-
#bpp_content ⇒ Object
Returns the value of attribute bpp_content.
-
#bpp_plays ⇒ Object
Returns the value of attribute bpp_plays.
-
#concord_content ⇒ Object
Returns the value of attribute concord_content.
-
#concord_plays ⇒ Object
Returns the value of attribute concord_plays.
-
#dps_content ⇒ Object
Returns the value of attribute dps_content.
-
#dps_plays ⇒ Object
Returns the value of attribute dps_plays.
-
#mti_content ⇒ Object
Returns the value of attribute mti_content.
-
#mti_plays ⇒ Object
Returns the value of attribute mti_plays.
-
#playscripts_content ⇒ Object
Returns the value of attribute playscripts_content.
-
#playscripts_plays ⇒ Object
Returns the value of attribute playscripts_plays.
Instance Method Summary collapse
- #bpp_index(url) ⇒ Object
- #bpp_info(url) ⇒ Object
- #concord_index(url) ⇒ Object
- #concord_info(url) ⇒ Object
- #dps_index(url) ⇒ Object
- #dps_info(url) ⇒ Object
- #mti_index(url) ⇒ Object
- #mti_info(url) ⇒ Object
- #playscripts_index(url) ⇒ Object
- #playscripts_info(url) ⇒ Object
Instance Attribute Details
#bpp_content ⇒ Object
Returns the value of attribute bpp_content.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def bpp_content @bpp_content end |
#bpp_plays ⇒ Object
Returns the value of attribute bpp_plays.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def bpp_plays @bpp_plays end |
#concord_content ⇒ Object
Returns the value of attribute concord_content.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def concord_content @concord_content end |
#concord_plays ⇒ Object
Returns the value of attribute concord_plays.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def concord_plays @concord_plays end |
#dps_content ⇒ Object
Returns the value of attribute dps_content.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def dps_content @dps_content end |
#dps_plays ⇒ Object
Returns the value of attribute dps_plays.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def dps_plays @dps_plays end |
#mti_content ⇒ Object
Returns the value of attribute mti_content.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def mti_content @mti_content end |
#mti_plays ⇒ Object
Returns the value of attribute mti_plays.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def mti_plays @mti_plays end |
#playscripts_content ⇒ Object
Returns the value of attribute playscripts_content.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def playscripts_content @playscripts_content end |
#playscripts_plays ⇒ Object
Returns the value of attribute playscripts_plays.
3 4 5 |
# File 'lib/prls/scraper.rb', line 3 def playscripts_plays @playscripts_plays end |
Instance Method Details
#bpp_index(url) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/prls/scraper.rb', line 124 def bpp_index(url) bpp_index = Nokogiri::HTML(open(url)) @bpp_plays = [] bpp_index.css('.product-details').each do |play| @bpp_plays << { :title => play.css('a').text.chomp(' [read more]'), :url => play.css('a').attribute('href').value } end @bpp_plays end |
#bpp_info(url) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/prls/scraper.rb', line 136 def bpp_info(url) bpp_data = Nokogiri::HTML(open(url)) play = bpp_data.css('.product-essential') @bpp_content = {:author => play.css('.authorbilling').text, :blurb => []} if play.css('.description p').first != nil @bpp_content[:summary] = play.css('.description p').first.text end play.css('#tab-reviews p').each do |review| if review != nil @bpp_content[:blurb] << review.text end end @bpp_content[:blurb] = @bpp_content[:blurb].join(' ') @bpp_content end |
#concord_index(url) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/prls/scraper.rb', line 39 def concord_index(url) concord_index = Nokogiri::HTML(open(url)) @concord_plays = [] concord_index.css('.card__item--text').each do |play| @concord_plays << { :title => play.css('a').text, :url => "https://www.concordtheatricals.com#{play.css('a').attribute('href').value}" } end @concord_plays end |
#concord_info(url) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/prls/scraper.rb', line 51 def concord_info(url) concord_info = Nokogiri::HTML(open(url)) @concord_content = { :author => concord_info.css('.type-large-credits').css('a').text, :summary => concord_info.css('.pdp-section .type-regular').css('.longer-content').text, :blurb => [] } concord_info.css('type-regular').css('.pdp-sub-section').each do |review| @concord_content[:blurb] << review.text end @concord_content[:blurb] = @concord_content[:blurb].join(' ') @concord_content end |
#dps_index(url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/prls/scraper.rb', line 10 def dps_index(url) dps_index = Nokogiri::HTML(open(url)) @dps_plays = [] dps_index.css('table td a').each do |play| if play != nil @dps_plays << { :title => play.text, :url => play.attribute('href').value } end end @dps_plays end |
#dps_info(url) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/prls/scraper.rb', line 25 def dps_info(url) dps_info = Nokogiri::HTML(open(url)) @dps_content = {} dps_info.css('#single').each do |content| @dps_content = { :author => content.css('#authorname').text, :summary => content.css('#lexisynopsis').text, :blurb => content.css('.lexishorttext').text } end @dps_content end |
#mti_index(url) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/prls/scraper.rb', line 65 def mti_index(url) mti_index = Nokogiri::HTML(open(url)) @mti_plays = [] mti_index.css('.alphabetical-item').each do |play| @mti_plays << { :title => play.css('span').text, :url => play.css('a').attribute('href').value } end @mti_plays end |
#mti_info(url) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/prls/scraper.rb', line 78 def mti_info(url) mti_data = Nokogiri::HTML(open(url)) @mti_content = {} mti_data.css('.group-content-main').each do |content| @mti_content = { :author => [], :summary => content.css('.show__summary').text, :blurb => content.css('.show__brief').text } end mti_data.css('.show__attributions .attribution__author-name').each do || @mti_content[:author] << .text end @mti_content[:author] = @mti_content[:author].uniq.join(', ') @mti_content end |
#playscripts_index(url) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/prls/scraper.rb', line 99 def playscripts_index(url) playscripts_index = Nokogiri::HTML(open(url)) @playscripts_plays = [] playscripts_index.css('.theater-story').each do |play| @playscripts_plays << { :title => play.css('.infos').css('.text').text, :url => "https://www.playscripts.com#{play.css('.infos').css('a').attribute('href').value}" } end @playscripts_plays end |
#playscripts_info(url) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/prls/scraper.rb', line 111 def playscripts_info(url) playscripts_info = Nokogiri::HTML(open(url)) @playscripts_content = { :summary => playscripts_info.css('.infos').css('.story-description').text.split.join(' ').chomp(' Read More'), :author => playscripts_info.css('.infos').css('.playauthors').css('a').text, } blurb_check = playscripts_info.css('.script-more-info').css('.content').css('.p-review').first if blurb_check != nil @playscripts_content[:blurb] = blurb_check.text.split.join(' ') end @playscripts_content end |