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

VERY slow on xpath getting TDs of a TR #66

Open
aimass opened this issue Nov 25, 2022 · 4 comments
Open

VERY slow on xpath getting TDs of a TR #66

aimass opened this issue Nov 25, 2022 · 4 comments

Comments

@aimass
Copy link

aimass commented Nov 25, 2022

Hi there!

If there's a mailing list pls. let me know and I'll post the discussion there.

This is taking 2 to 3 seconds on average:
my @cells = $mech->xpath('.//td', node => $rows[$row_index]);

what is making it so slow ?? Is there a way to speed this?

TIA!

--
Alex

@aimass
Copy link
Author

aimass commented Nov 25, 2022

UPDATE: the time seems to be proportional to the number of rows. The 2-3 second timing is for a table with 450 rows and 12 columns. On a table with 120 rows, it's less than a second.
Speculating: it would seem that relative to node xpath has some bug and may be scanning the whole table each time.

@Corion
Copy link
Owner

Corion commented Nov 25, 2022

See also this post. Most helpful would be a short, self-contained script to reproduce the issue.

@aimass
Copy link
Author

aimass commented Nov 26, 2022

Sure thing, I'll try to replicate the issue with some public site that has a table with a few hundred records, and follow up here and on PM.BTW, I actually wrote that post on PM ;-)

I updated that post and added a workaround at the end combining W::M::Chrome xpath to find the table node and then HTML::Tree to parse the table. I think this actually a good approach and reduces the Chrome overhead anyways.

@aimass
Copy link
Author

aimass commented Nov 26, 2022

Here you go: https://perlmonks.org/?node_id=11148399

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