Ruby Nokogiri刮削

Ruby Nokogiri刮削,ruby,nokogiri,Ruby,Nokogiri,我想取消每个视频的标题和链接 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 有人能帮忙吗!你已经花了一个小时的时间来研究它了,但还没

我想取消每个视频的标题和链接

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

有人能帮忙吗!你已经花了一个小时的时间来研究它了,但还没弄明白。你可以用
css
方法找到链接,然后在集合上迭代以提取
href
属性。例如:

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