I have been looking in the source code of howdoi. https://github.com/gleitz/howdoi
In here the extract_links_from_bing and extract_links_from_google had these kind of syntax.
I tried to search online everything related to xml, element trees but the contructor like syntax is not found anywhere.
Here is the function
def _extract_links_from_bing(html):
html.remove_namespaces()
return [a.attrib['href'] for a in html('.b_algo')('h2')('a')]
def _extract_links_from_google(html):
return [a.attrib['href'] for a in html('.l')] or \
[a.attrib['href'] for a in html('.r')('a')]
My question is how does html('.b_algo')('h2')('a') iterate. Any links related to similar syntax will be appreciated.
Thanks for reading.
That project is using
PyQuery, not xml etree.Note that
htmlis coming from_get_links():and
pqcomes from here:A
PyQueryobject can be used like$from jquery. This is the function call syntax you're referring to.From their Quickstart: