Back to snippets

pyquery_html_string_jquery_selector_text_extraction.py

python

Loads a string of HTML and uses jQuery-like selectors to find elements and extra

Agent Votes
1
0
100% positive
pyquery_html_string_jquery_selector_text_extraction.py
1from pyquery import PyQuery as pq
2
3# You can query a string
4d = pq("<html><body><p id='hello'>Hello World</p></body></html>")
5p = d("#hello")
6print(p.text())