Reputation: 211
I'd like to scrap the title of each video and the links.
doc = Nokogiri::HTML(open('http://www.stream2u.me/'))
doc.css('.lshpanel').each do |link|
binding.pry
puts link.elements[1].text
puts "LINKS ARE: "
## Cant figure out how to get to the links...
end
Can someone please help! Been working on it for like an hour and cant figure it out.
Upvotes: 0
Views: 88
Reputation: 5283
You can locate the links with the css
method and then iterate over the collection to pull the href
attributes. For example:
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.stream2u.me/'))
doc.css('.lshpanel').each do |d|
puts d.css('.lshevent').text
d.css('a').each { |el| puts el['href'] }
end
Upvotes: 1