forked from ashi009/node-fast-html-parser
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Can't select some element. #203
Labels
Comments
I'm afraid I could not find where the problem is. const vimeoHtml = parse(`<div class="clip_details-description description-wrapper iris_desc">
<p class="first">Country music legend, Trish Cotton, has something to say.</p>
<p>
Written by Kyle Kasabian (@kylekasabian) <br />
Directed by Derek Mari (@directorderek)<br />
Director of Photography: Peter Mickelsen<br />
Produced by Derek Mari and Kyle Kasabian<br />
Edited by Derek Mari
</p>
<p>Starring: Alyssa Sabo, Janine Hogan, and Kyle Kasabian</p>
<p>
Assistant Camera: Casey Schoch<br />
Production Sound: David Alvarez<br />
Production Assistant: Keith Ahlstrom
</p>
<p>Music by Morgan Matthews</p>
<p>
Blink & Miss Productions<br />
Bad Cat Films
</p>
</div>
</div>`);
const description = vimeoHtml.querySelector('.description-wrapper');
description.toString().should.eql('<ul id="list"><li><a href="#">Some link</a></li></ul>'); |
I'm not sure if this is exactly related, but this outputs " import { parse } from "node-html-parser";
console.log(
parse(
`<html><body><pre><code class="language-typescript">type Foo = { foo: 'bar' }</code></pre></body></html>`
).querySelector("code")
); |
It seems like the bug is in the import { parse } from "node-html-parser";
const convert = root => ({
tag: root.tagName,
textContent: root.textContent,
children: [...root.childNodes].map(convert),
});
const tree = convert(
parse(`<html><body><pre><code class="language-typescript">type Foo = { foo: 'bar' }</code></pre></body></html>`)
);
console.log(JSON.stringify(tree, null, 2)); This outputs: {
"tag": null,
"textContent": "<code class=\"language-typescript\">type Foo = { foo: 'bar' }</code>",
"children": [
{
"tag": "HTML",
"textContent": "<code class=\"language-typescript\">type Foo = { foo: 'bar' }</code>",
"children": [
{
"tag": "BODY",
"textContent": "<code class=\"language-typescript\">type Foo = { foo: 'bar' }</code>",
"children": [
{
"tag": "PRE",
"textContent": "<code class=\"language-typescript\">type Foo = { foo: 'bar' }</code>",
"children": [
{
"textContent": "<code class=\"language-typescript\">type Foo = { foo: 'bar' }</code>",
"children": []
}
]
}
]
}
]
}
]
} |
@wolfie try this parse(html, {
blockTextElements: {
script: true,
noscript: true,
style: true,
}
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to fetch the title and description of a Vimeo video. I brought the HTML successfully. But I can't select the description
div
.Here is the code:
this code brings the HTML. The HTML contains a div with class
description-wrapper
.But when I try to select the div by
querySelector
it returns null.The text was updated successfully, but these errors were encountered: