Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6370089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:53:09+00:00 2026-05-25T00:53:09+00:00

I know this question has been asked earlier but I am not able to

  • 0

I know this question has been asked earlier but I am not able to get the parsed result. I am trying to parse metawords using nokogiri, can any one point out my mistake?

keyword = []
meta_data = doc.xpath('//meta[@name="Keywords"]/@content')                                         #parsing for keywords
meta_data.each do |meta|
  keyword << meta.value
end
key_str=keyword.join(",")

I tried running this in irb as well but keyword returns a nil.

This is how I used it in irb

 require 'rubygems'  
 require 'nokogiri'
 doc = Nokogiri::HTML("www.google.com") 

have already tried alternatives from other stackoverflow posts like
Nokogiri html parsing question but of no use, they still return nil. I guess i am doing something wrong somewhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:53:10+00:00Added an answer on May 25, 2026 at 12:53 am
    1. http://www.google.com does not have any meta keywords in the source. View Source on the page to see for yourself. So even if everything else went perfectly, you’d still get no results there.

    2. The result of doc = Nokogiri::HTML("www.google.com") is

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
      <html><body><p>www.google.com</p></body></html>
      

      If you want to fetch the contents of a URL, you want to use something like:

      require 'open-uri'
      doc = Nokogiri::HTML( open('http://www.google.com' ) )
      
    3. If you get a valid HTML page, and use the proper casing on keywords to match the source, it works fine. Here’s an example from my IRB session, fetching a page from one of the apps on my site that happens to use name="keywords" instead of name="Keywords":

      irb(main):001:0> require 'open-uri'
      #=> true
      irb(main):002:0> require 'nokogiri'
      #=> true
      irb(main):003:0> url = "http://pentagonalrobin.phrogz.net/choose"
      #=> "http://pentagonalrobin.phrogz.net/choose"
      irb(main):04:0> doc = Nokogiri::HTML( open(url) ); nil # don't show doc here
      #=> nil
      irb(main):005:0> doc.xpath('//meta[@name="keywords"]/@content').map(&:value)
      #=> ["team schedule free round-robin league"]
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked before, but I haven't been able to
I know this specific question has been asked before , but I am not
I know this question has been asked before but the solutions did not work
I know this question has been asked lots of times, but I am not
I know this question has been asked a lot, but not yet to my
I know this question has been asked many times, but I have not been
I know this question has been asked multiple times, but nobody has been able
I know this question has been asked before, but I ran into a problem.
I know this question has been asked a bit before. But looking around I
I know this question has been asked before numorous times but they seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.