I am using requests-html and trying the render function, with little success. When I run this script using python3.8
#!/usr/bin/python3
from requests_html import HTML
file = "scrape/temp_file2.html"
with open(file) as html_file:
source = html_file.read()
html = HTML(html=source)
html.render()
match = html.find('#footer', first=True)
try:
print(match.hmtl)
except:
print('not found')
it results in a traceback:
python3 scrape/test1.py
Traceback (most recent call last):
File "scrape/test1.py", line 10, in <module>
html.render()
File "/home/pi/.local/lib/python3.8/site-packages/requests_html.py", line 586, in render
self.browser = self.session.browser # Automatically create a event loop and browser
File "/home/pi/.local/lib/python3.8/site-packages/requests_html.py", line 730, in browser
self._browser = self.loop.run_until_complete(super().browser)
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/pi/.local/lib/python3.8/site-packages/requests_html.py", line 714, in browser
self._browser = await pyppeteer.launch(ignoreHTTPSErrors=not(self.verify), headless=True, args=self.__browser_args)
File "/home/pi/.local/lib/python3.8/site-packages/pyppeteer/launcher.py", line 306, in launch
return await Launcher(options, **kwargs).launch()
File "/home/pi/.local/lib/python3.8/site-packages/pyppeteer/launcher.py", line 147, in launch
self.proc = subprocess.Popen( # type: ignore
File "/usr/local/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/pi/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome'
The chromium file is an executable:
ls -l /home/pi/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome
-rwxr-xr-x 1 pi pi 214121928 Mar 9 17:21 /home/pi/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome
If I remove the html.render() line it works fine (but won't render the javascript). Any ideas?
file /home/pi/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome
, does it identify it as an executable that matches your CPU? – Logistic