I have a moderately simple problem, and I am trying to figure out the best approach to implement it.
For those wondering, this is used to scrape data from a non-editable page (can add css,js, but the rest of the content is closed source and not available for editing)
I am iterating through an element (tr for example), and I only want to look at the cases where a certain number of td elements are present.
Eg, For every tr, I only want to consider the case where it has 3 td children
What is the best way to do that?
You could try something like this:
You can then do any kind of scraping you like. A simple example:
As @patrick points out below, you can of course chain the scraping process directly to the output of the
filter()if it makes sense for your code.Edit: Added
'td'selector inchildren(). Belt and suspenders.Edit: Added example of how to walk through results, as per OP comment.