xpath selectors with position() return incorrect data in python
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I am using lxml with XPath selectors to get the content of a table on this page:
https:/
I need to get the fields of the second table.
If I open Chrome Web tools I can get the expected results with any one of these XPath selectors:
1. $x('//div[
2. $x('//div[
3. $x('//div[
4. $x('//div[
However, only the 4th selector returns the expected results from a Python script which uses lxml.html.
### Minimal reproducible example
```python
import requests
import lxml.html
PAGE = 'https:/
XPATH_SELECTOR = '//div[
res = requests.get(PAGE)
root = lxml.html.
fields = root.xpath(
assert len(fields) == 17
```
### My environment
```sh
Python : sys.version_
lxml.etree : (4, 2, 5, 0)
libxml used : (2, 9, 8)
libxml compiled : (2, 9, 8)
libxslt used : (1, 1, 32)
libxslt compiled : (1, 1, 32)
```
XPath is implemented in libxml2, not in lxml.