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

Using Playwright or Pupperteer do not work for me with extractFromHtml() #389

Closed
onigetoc opened this issue May 1, 2024 · 1 comment
Closed

Comments

@onigetoc
Copy link

onigetoc commented May 1, 2024

Using Playwright or Pupperteer do not work for me with extractFromHtml()

I tried everything like:

Get the HTML to send to article-extractor
const contentHTML = await page.locator('html').innerHTML();
OR
const htmlPageContent = await page.content();

For testing where i use Playwright i did try with:
const contentExtractHtmlArticle = await articleExtractor(htmlPageContent);

I did a extract.ts file with a export fonction.

I tried this in my export page:
const { content } = await extractFromHtml(html);
OR
const { content } = await extractFromHtml(String(html));

I import my fonction where i use Playwright just to tested if i got a async await error.
But if i use from url in my export function, i tryed in the below section with extrac(url) and it did work.

but did not work when sending html:

export async function articleExtractor(html) {
    try {
      const { content } = await extractFromHtml(html);
      // GC isHTML IN utils.js NOTE: nothing to do with the error i removed this isHTML part to test more.
      if (isHTML(content)) {
        console.log('HTML found');
        return content ;
      } else {
        console.log('HTML NOT found');
        return 'text/html not found';
      }
    } catch (error) {
      console.error('Error extracting text from HTML:', error);
      return 'Error extracting text from HTML';
    }
  }
@ndaidong ndaidong mentioned this issue May 7, 2024
@ndaidong
Copy link
Collaborator

ndaidong commented May 7, 2024

@onigetoc I've added an example with pupperteer, please refer and try to apply it to your scenario.

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

2 participants