首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法加载这样的文件-- whois/server/adapters/verisign

无法加载这样的文件-- whois/server/adapters/verisign
EN

Stack Overflow用户
提问于 2019-01-31 12:59:57
回答 2查看 75关注 0票数 0

我正在尝试创建一个简单的ruby on rails应用程序来输出whois信息。我是新来ruby的,所以请耐心等待。

代码语言:javascript
复制
require 'whois'
require 'whois-parser'

我的控制器:

代码语言:javascript
复制
class WhoisController < ApplicationController
  def index
    whois = Whois::Client.new    
    msg = {:token => whois.lookup("google.com")}
    render :json => msg
  end
end

我得到一个错误:

代码语言:javascript
复制
cannot load such file -- whois/server/adapters/verisign

编辑:

当我需要运行ruby包whois google.com时,建议运行json将运行系统调用whois,因为我需要能够为每个字段提供json输出。查找"Registrar IANA ID“等。whois google.com的输出是:

代码语言:javascript
复制
{"whois":"   Domain Name: GOOGLE.COM\n   Registry Domain ID: 2138514_DOMAIN_COM-VRSN\n   Registrar WHOIS Server: whois.markmonitor.com\n   Registrar URL: http://www.markmonitor.com\n   Updated Date: 2018-02-21T18:36:40Z\n   Creation Date: 1997-09-15T04:00:00Z\n   Registry Expiry Date: 2020-09-14T04:00:00Z\n   Registrar: MarkMonitor Inc.\n   Registrar IANA ID: 292\n   Registrar Abuse Contact Email: abusecomplaints@markmonitor.com\n   Registrar Abuse Contact Phone: +1.2083895740\n   Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited\n   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited\n   Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited\n   Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited\n   Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited\n   Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited\n   Name Server: NS1.GOOGLE.COM\n   Name Server: NS2.GOOGLE.COM\n   Name Server: NS3.GOOGLE.COM\n   Name Server: NS4.GOOGLE.COM\n   DNSSEC: unsigned\n   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/\n\u003e\u003e\u003e Last update of whois database: 2019-02-02T02:42:36Z \u003c\u003c\u003c\n\nFor more information on Whois status codes, please visit https://icann.org/epp\n\nNOTICE: The expiration date displayed in this record is the date the\nregistrar's sponsorship of the domain name registration in the registry is\ncurrently set to expire. This date does not necessarily reflect the expiration\ndate of the domain name registrant's agreement with the sponsoring\nregistrar.  Users may consult the sponsoring registrar's Whois database to\nview the registrar's reported date of expiration for this registration.\n\nTERMS OF USE: You are not authorized to access or query our Whois\ndatabase through the use of electronic processes that are high-volume and\nautomated except as reasonably necessary to register domain names or\nmodify existing registrations; the Data in VeriSign Global Registry\nServices' (\"VeriSign\") Whois database is provided by VeriSign for\ninformation purposes only, and to assist persons in obtaining information\nabout or related to a domain name registration record. VeriSign does not\nguarantee its accuracy. By submitting a Whois query, you agree to abide\nby the following terms of use: You agree that you may use this Data only\nfor lawful purposes and that under no circumstances will you use this Data\nto: (1) allow, enable, or otherwise support the transmission of mass\nunsolicited, commercial advertising or solicitations via e-mail, telephone,\nor facsimile; or (2) enable high volume, automated, electronic processes\nthat apply to VeriSign (or its computer systems). The compilation,\nrepackaging, dissemination or other use of this Data is expressly\nprohibited without the prior written consent of VeriSign. You agree not to\nuse electronic processes that are automated and high-volume to access or\nquery the Whois database except as reasonably necessary to register\ndomain names or modify existing registrations. VeriSign reserves the right\nto restrict your access to the Whois database in its sole discretion to ensure\noperational stability.  VeriSign may restrict or terminate your access to the\nWhois database for failure to abide by these terms of use. VeriSign\nreserves the right to modify these terms at any time.\n\nThe Registry database contains ONLY .COM, .NET, .EDU domains and\nRegistrars.\n"}

编辑#2以下是普通的老红宝石作品:

代码语言:javascript
复制
require "whois"
require "whois-parser"
require "json"

class MyWhoIs
  def initialize(site)
    @site = site
  end
  def index
    whois = Whois::Client.new
    record = Whois.whois("#{@site}")
    parser = record.parser
    puts parser.created_on
  end
end

who = MyWhoIs.new("google.com")
who.index

打印"1997-09-15 00:00:00 -0700“

为什么它不能在Rails中工作?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-01-31 13:31:56

whois/server/adapters/verisign是gem上的一个文件,尝试重新安装gem

代码语言:javascript
复制
gem uninstall whois
gem install whois

另一种解决方案是下载gem源代码并更新gem文件。

代码语言:javascript
复制
cd /your/path/
git clone git@github.com:weppos/whois.git

在你的Gemfile上

代码语言:javascript
复制
gem 'whois', path: '/your/path/whois'

从源代码安装gem

代码语言:javascript
复制
cd /your/path/whois
gem build whois.gemspec
gem install whois-x.y.z.gem

在此之后,将Gemfile更新为

代码语言:javascript
复制
gem 'whois'
票数 1
EN

Stack Overflow用户

发布于 2019-01-31 13:11:38

在不需要外部gem的情况下本机执行此命令。调用bash函数

代码语言:javascript
复制
`echo 'hello world'`

所以

代码语言:javascript
复制
class WhoisController < ApplicationController
  def index
    whois = Whois::Client.new    
    msg = {:token => `whois google.com`}
    render :json => msg
  end
end
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54453590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档