`I have a code in python to read xpath from a website (https://www.op.gg/summoners/kr/Hide%20on%20bush)
import requests
import lxml.html as html
import pandas as pd
url_padre = "https://www.op.gg/summoners/br/tercermundista"
link_farm = '//div[@class="stats"]//div[@class="cs"]'
r = requests.get(url_padre)
home=r.content.decode("utf-8")
parser=html.fromstring(home)
farm=parser.xpath(link_farm)
print(farm)`
this code print "[]"
but when in the console chrome put this xpath: $x('//div[@class="stats"]//div[@class="cs"]').map(x=>x.innerText), this print the numbers i want, but my python code dont do it What is the mistake?
i want a code to solve my mistake
--------------------------edit---------------------------
Error Traceback (most recent call last)
c:\Users\GCO\Desktop\Analisis de datos\borradores\fsdfs.ipynb Cell 2 in 3
1 from playwright.sync_api import sync_playwright
----> 3 with sync_playwright() as p, p.chromium.launch() as browser:
4 page = browser.new_page()
5 page.goto("https://www.op.gg/summoners/kr/Hide%20on%20bush", timeout=10000)
File c:\Users\GCO\AppData\Local\Programs\Python\Python310\lib\site-packages\playwright\sync_api\_context_manager.py:47, in PlaywrightContextManager.__enter__(self)
45 self._own_loop = True
46 if self._loop.is_running():
---> 47 raise Error(
48 """It looks like you are using Playwright Sync API inside the asyncio loop.
49 Please use the Async API instead."""
50 )
52 # In Python 3.7, asyncio.Process.wait() hangs because it does not use ThreadedChildWatcher
53 # which is used in Python 3.8+. This is unix specific and also takes care about
54 # cleaning up zombie processes. See https://bugs.python.org/issue35621
55 if (
56 sys.version_info[0] == 3
57 and sys.version_info[1] == 7
58 and sys.platform != "win32"
59 and isinstance(asyncio.get_child_watcher(), asyncio.SafeChildWatcher)
60 ):
Error: It looks like you are using Playwright Sync API inside the asyncio loop.
Please use the Async API instead.