私有方法`split'调用nil:NilClass(NoMethodError) [英] private method `split' called for nil:NilClass (NoMethodError)

查看:271
本文介绍了私有方法`split'调用nil:NilClass(NoMethodError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用nokogiri来使用domainatrix,并拿出一个劫持。对于ruby来说相对来说比较陌生,我已经尝试了Domainatrix.parse函数中的每个语法变体,以便我可以正确解析href。他们在puts命令期间进行打印,但是当我取消对domainatrix代码问题的注释时:开始:

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

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

linkage = node.text
$ b $联动
$ b $ url = Domainatrix.parse(联动)
打印url.domain
打印url.public_suffix

结束

任何人对此有任何想法?我认为这只是一个语法问题,或者我不能在使用Domainatrix函数的地方使用它?

解决方案


被一些格式不正确的网址占用。

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?

解决方案

It was getting snagged on some improperly formatted URLs.

这篇关于私有方法`split'调用nil:NilClass(NoMethodError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆