Supercharged-Web-Scraping-with-Asyncio icon indicating copy to clipboard operation
Supercharged-Web-Scraping-with-Asyncio copied to clipboard

Code at lesson 6 raises Error

Open alek-tech opened this issue 3 years ago • 0 comments

Hello, when i tried to run the code of lesson 6 i got the following traceback:

Traceback (most recent call last): File "c:\Users\alek\Desktop\arsenic test scraper.py", line 45, in asyncio.run(scraper(url)) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "c:\Users\alek\Desktop\arsenic test scraper.py", line 34, in scraper async with get_session(service, browser) as session: File "C:\Users\alek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\arsenic_init_.py", line 16, in aenter self.session = await start_session(self.service, self.browser, self.bind) File "C:\Users\alek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\arsenic_init_.py", line 28, in start_session driver = await service.start() File "C:\Users\alek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\arsenic\services.py", line 122, in start return await subprocess_based_service( File "C:\Users\alek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\arsenic\services.py", line 39, in subprocess_based_service process = await impl.start_process(cmd, log_file) File "C:\Users\alek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\arsenic\subprocess.py", line 56, in start_process return await asyncio.create_subprocess_exec( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\subprocess.py", line 218, in create_subprocess_exec transport, protocol = await loop.subprocess_exec( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 1652, in subprocess_exec transport = await self._make_subprocess_transport( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\windows_events.py", line 394, in _make_subprocess_transport transp = _WindowsSubprocessTransport(self, protocol, args, shell, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\base_subprocess.py", line 36, in init self._start(args=args, shell=shell, stdin=stdin, stdout=stdout, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\windows_events.py", line 890, in _start self._proc = windows_utils.Popen( File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\asyncio\windows_utils.py", line 153, in init super().init(args, stdin=stdin_rfd, stdout=stdout_wfd, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 966, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1435, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified

I solved the issue though by pip installing chromedriver-autoinstaller which downloads and installs chromedriver that supports the currently installed version of chrome.

and adding the following code to the script:

under the rest of the imports

import chromedriver_autoinstaller chromedriver_autoinstaller.install()

alek-tech avatar Mar 22 '22 19:03 alek-tech