private method `split' called for nil:NilClass (NoMethodError)

佐手、 提交于 2019-12-13 04:13:17

问题


I'm trying to use domainatrix with nokogiri and am coming up with a holdup. Being relatively new to ruby, I've tried every syntax variation on the Domainatrix.parse function I can to get the a href's to parse properly. They do print during the "puts" command but when I uncomment the domainatrix code problems start:

require 'rubygems'
require 'domainatrix'
require 'anemone'
require 'open-uri'
require 'nokogiri'

doc = Nokogiri::HTML(open("http://www.cnn.com"))
doc.xpath('//a/@href').each do |node|

  linkage = node.text

  puts linkage

  url = Domainatrix.parse(linkage)
  print url.domain
  print url.public_suffix

end

Anyone have any ideas on this? I think it is just a syntax issue or perhaps I cannot use the Domainatrix function where I'm using it?


回答1:


It was getting snagged on some improperly formatted URLs.



来源:https://stackoverflow.com/questions/3404932/private-method-split-called-for-nilnilclass-nomethoderror

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!