Skip to content

lxml.etree.XPathEvalError_Invalid expression #515

Closed
@tellts

Description

VSC, Windows 10, Python 3.9.5

# lesson https://www.youtube.com/watch?v=MeBU-4Xs2RU&t=2s
from requests_html import HTMLSession
url = 'https://www.beerwulf.com/en-gb/c/beers?segment=Beers&catalogCode=Beer_1'
s = HTMLSession()
r = s.get(url)
r.html.render(sleep=2)
#print(r.status_code) #200
products = r.html.xpath('//*[@id="product-items-container"], first = True')
print(products)

> & C:/python39/python.exe c:/parsing/2020/a3test.py
Traceback (most recent call last):
  File "c:\parsing\2020\a3test.py", line 8, in <module>
    products = r.html.xpath('//*[@id="product-items-container"], first = True')
  File "C:\python39\lib\site-packages\requests_html.py", line 255, in xpath
    selected = self.lxml.xpath(selector)
  File "src\lxml\etree.pyx", line 1599, in lxml.etree._Element.xpath
  File "src\lxml\xpath.pxi", line 305, in lxml.etree.XPathElementEvaluator.__call__
  File "src\lxml\xpath.pxi", line 225, in lxml.etree._XPathEvaluatorBase._handle_result
lxml.etree.XPathEvalError: Invalid expression
PS C:\parsing\2020> 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions