I've set up a Python script to open this web page with PyQuery.
import requests
from pyquery import PyQuery
url = "http://www.floridaleagueofcities.com/widgets/cityofficials?CityID=101"
page = requests.get(url)
pqPage = PyQuery(page.content)
But pqPage("li") returns only a blank list, []. Meanwhile, pqPage.text() shows the text of the page's HTML, which includes li elements.
Why won't the code return a list of li elements? How do I make it do that?
In seems
PyQueryhas problem to work with this page - maybe because it isxhtmlpage. Or maybe because it use namespacexmlns="http://www.w3.org/1999/xhtml"When I use
then I get
which shows
{http://www.w3.org/1999/xhtml}in element - it isnamespace. Some modules has problem withHTMLwhich uses namespaces.I have no problem to get it using
BeautifulsoupEDIT: after digging in Google I found that using
parser="html"inPyQuery()I can getli.