简体   繁体   English

私有方法`split'调用了nil:NilClass(NoMethodError)

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

I'm trying to use domainatrix with nokogiri and am coming up with a holdup. 我正在尝试将domainatrix与nokogiri结合使用,并提出了一个要求。 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. 对于红宝石而言,我还比较陌生,所以我尝试了Domainatrix.parse函数上的每种语法变体,以获得可以正确解析的a href。 They do print during the "puts" command but when I uncomment the domainatrix code problems start: 它们确实在“ puts”命令期间打印,但是当我取消注释domainatrix代码时,问题开始了:

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? 我认为这只是一个语法问题,或者也许我不能在使用它的地方使用Domainatrix函数?

它被某些格式不正确的URL所卡住。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 私有方法`select'调用了nil:NilClass(NoMethodError) - private method `select' called for nil:NilClass (NoMethodError) 私有方法“ chomp”调用了nil:NilClass(NoMethodError) - private method `chomp' called for nil:NilClass (NoMethodError) 私有方法`puts'调用nil:NilClass(NoMethodError) - private method `puts' called for nil:NilClass (NoMethodError) 私有方法`split'要求nil:NilClass - private method `split' called for nil:NilClass 未定义的方法'split'为nil:NilClass(NoMethodError) - undefined method 'split' for nil:NilClass (NoMethodError) nil的未定义方法`split':数组的NilClass(NoMethodError) - undefined method `split' for nil:NilClass (NoMethodError) for an array Minitest: NoMethodError: nil:NilClass 的未定义方法`split' - Minitest: NoMethodError: undefined method `split' for nil:NilClass Ruby 2.1:组成零件自行车->调用nil:NilClass的私有方法“ select”(NoMethodError) - Ruby 2.1: Composing a Bicycle of Parts -> private method `select' called for nil:NilClass (NoMethodError) NoMethodError:未定义的方法“+”用于 nil:NilClass 用于私有方法中的变量 - NoMethodError: undefined method `+' for nil:NilClass for variable in private method 错误(为nil:NilClass调用了私有方法“ select”): - Error (private method `select' called for nil:NilClass):
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM