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

extractFromHtml() returns null #335

Closed
shipcommit opened this issue Mar 25, 2023 · 6 comments
Closed

extractFromHtml() returns null #335

shipcommit opened this issue Mar 25, 2023 · 6 comments

Comments

@shipcommit
Copy link

shipcommit commented Mar 25, 2023

extract() works fine, and returns the expected output.

When extracting data with extractFromHtml(), I get null.

I have tried the following examples, and they all return null.

const res = await fetch(url)
const html = await res.text()

const article = await extractFromHtml(html)

console.log(article);
const response = await got(url);

const data = await extractFromHtml(response.body);

console.log(data);
@shipcommit
Copy link
Author

I would assume this data would work as the input, but it doesn't:
Skjermbilde 2023-03-25 103309

@ndaidong
Copy link
Collaborator

@shipcommit thank you, I will check this case asap.

@ndaidong
Copy link
Collaborator

ndaidong commented Mar 28, 2023

@shipcommit hello, I could not reproduce the error as what you faced. Native fetch and got both work for me.
Please share more info about your use case:

  • Platform (e.g, Node.js 18.5.0, Bun 0.5.2, etc)
  • Article Extractor version
  • Your script in detail, url to extract, etc

Thank you.

@houshuang
Copy link

I get the same with this URL https://en.wikipedia.org/wiki/Plato, but exactly the same setup with this URL worked flawlessly. https://www.aftenposten.no/norge/i/69V75W/terrorsiktede-soestre-fra-baerum-paagrepet-av-pst

Would be nice if it could return the reason why it returns null, to make it easier to diagnose.

@houshuang
Copy link

Never mind, I figured it out - it was due to some pre-processing I was doing. Would still be nice with better error messages.

@ndaidong
Copy link
Collaborator

@houshuang thank you for your info and suggestion.

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

No branches or pull requests

3 participants