Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fecthing meta #322

Closed
hemanth opened this issue Dec 8, 2013 · 7 comments
Closed

Fecthing meta #322

hemanth opened this issue Dec 8, 2013 · 7 comments

Comments

@hemanth
Copy link

hemanth commented Dec 8, 2013

W.R.T nom#2

@jugglinmike
Copy link
Member

Hi @hemanth ,

I'm unable to reproduce this (based on my understanding of the issue). Here's the script I'm running:

var cheerio = require('..');
var markup = [
  '<html>',
  '<head>',
  '<meta http-equiv="refresh">',
  '</head>',
  '<body>',
  '<h1>Hello, world!</h1>',
  '</body>',
  '</html>'
].join('');

var $ = cheerio.load(markup);

console.log(cheerio.version);

console.log($.html('h1'));

console.log($.html('meta'));
console.log($.html('meta[http-equiv="refresh"]'));
console.log($.html('meta[http-equiv=\'refresh\']'));

..and the output, as expected:

0.12.4
<h1>Hello, world!</h1>
<meta http-equiv="refresh">
<meta http-equiv="refresh">
<meta http-equiv="refresh">

Could you share the output of that script when run on your machine? If it is identical, could you share a simple test case using Cheerio directly?

One problem that comes to mind is that nom may be using an old version of Cheerio. If nom is installed globally, you could try the following:

$ npm uninstall -g nom
$ npm cache clean
$ npm install nom

@hemanth
Copy link
Author

hemanth commented Dec 10, 2013

@jugglinmike It works fine that way for me too. Does nom <url> meta work?

@jugglinmike
Copy link
Member

I don't really know much about nom, but it looks like it is built to return the inner HTML of the first element matched by the selector. If that's correct, then nom <url> meta should normally return an empty string, since meta tags typically do not contain child nodes and therefore do not define any inner HTML. That interpretation matches the behavior I'm seeing.

@hemanth
Copy link
Author

hemanth commented Dec 12, 2013

@jugglinmike Yes the same is been discussed at nom#2 :

if(selector === "meta"){
   console.log($(selector));
}

@jugglinmike
Copy link
Member

@hemanth I don't quite understand what that example is intended to demonstrate. My interpretation of the behavior is that there is no issue, so tell me where I'm wrong:

nom <url> meta should return the innerHTML of the first meta tag in the document at the given <url>. Because meta tags do not have childnodes, nom is correctly returning an empty string.

@fb55
Copy link
Member

fb55 commented Feb 23, 2014

I guess @jugglinmike got it right :)

@fb55 fb55 closed this as completed Feb 23, 2014
@askucher
Copy link

I does not fetch meta for me as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants