pyquery icon indicating copy to clipboard operation
pyquery copied to clipboard

failure to locate elements

Open gawel opened this issue 12 years ago • 2 comments

Lane Stevens created an issue 2012-07-18

I have include two files. The first file is a proper subset of the second. In the first file, the p and div elements are not found. In the second file the p and div elements are correctly found.

This issue was found in using PyQuery via WebTest but it fails when using PyQuery directly. The version in use is 1.2.1.

Example:

from pyquery import PyQuery
f = open('f1','r')
s = f.read()
f.close()
d = PyQuery(s)
print len(d('p')) #should be 1 for both files

Files at https://bitbucket.org/olauzanne/pyquery/issue/54/failure-to-locate-elements

gawel avatar Nov 28 '12 20:11 gawel

initial trace, there is a slightly difference on pyquery.py:69 f2.html will cause "etree.XMLSyntaxError" by the &copy, and use lxml.html parser to parse the result, and get the right result OAO

yodalee avatar Aug 30 '14 13:08 yodalee

I think this is related to issue #31, that XMLSyntaxError cause lxml use html parser, and get the right result in the end.

yodalee avatar Sep 01 '14 00:09 yodalee