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

Cannot parse header and one column contain DOM elements. #413

Open
TimKieu opened this issue Aug 27, 2024 · 2 comments
Open

Cannot parse header and one column contain DOM elements. #413

TimKieu opened this issue Aug 27, 2024 · 2 comments
Assignees

Comments

@TimKieu
Copy link

TimKieu commented Aug 27, 2024

Please help.
I am crawling a table which its header and one column contain DOM elements, not plain text as the examples.
The error mentions about settings and conversion exception on those.

@Tomas2D
Copy link
Owner

Tomas2D commented Aug 29, 2024

Can I see such HTML Table so I can debug it?

@Tomas2D Tomas2D self-assigned this Sep 14, 2024
@Tomas2D
Copy link
Owner

Tomas2D commented Sep 14, 2024

If your table looks like this

<table id="table-overview">
  <thead>
  <tr>
    <th>A</th>
    <th><input type="checkbox" checked></th>
    <th>C</th>
  </tr>
  </thead>
  <tbody>
  <tr>
    <td>A1</td>
    <td>B1</td>
    <td><img src='#' alt='image'>C1</td>
  </tr>
  <tr>
    <td><a href='#'>A1</a></td>
    <td><input type="checkbox" checked></td>
    <td>C1</td>
  </tr>
  </tbody>
</table>

Then you can do this

    const data = await tableParser(page, {
      selector: '#table-overview',
      asArray: false,
      allowedColNames: {
        'A': 'A',
        '': 'B',
        'C': 'C',
      }
    });

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