我正在遵循有关网络抓取https://www.linkedin.com/pulse/how-easy-scraping-data-from-linkedin-profiles-david-craven/的本教程。 python脚本正在生成错误,我已经尝试将目录添加到PATH,并且在我回显屏幕路径时会显示该目录,但是现在当应该只存在一个目录时,它将显示“ / Users / owner / Users / owner”路径中的“用户/所有者”。
我在macOS High Sierra中使用bash,并且是数据科学专业的人,因此DevOps对我来说是一个挑战,同时也要学习如何将代码发布到StackOverflow,但我正在尝试记录我的步骤,因此更容易解决此问题。
from selenium import webdriver
driver = webdriver.Chrome('~/Users/owner/sbox/test/pandas_sqlite_dbase/googlechrome')
driver.get('https://www.linkedin.com')
现在我遇到了追溯错误
Traceback (most recent call last):
File "/Users/owner/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Users/owner/anaconda3/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Users/owner/anaconda3/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '~/Users/owner/sbox/test/pandas_sqlite_dbase/googlechrome': '~/Users/owner/sbox/test/pandas_sqlite_dbase/googlechrome'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/owner/sbox/test/pandas_sqlite_dbase/scraping_tutorial.py", line 7, in <module>
driver = webdriver.Chrome('~/Users/owner/sbox/test/pandas_sqlite_dbase/googlechrome')
File "/Users/owner/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Users/owner/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'googlechrome' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
[Finished in 0.7s with exit code 1]
[shell_cmd: python -u "/Users/owner/sbox/test/pandas_sqlite_dbase/scraping_tutorial.py"]
[dir: /Users/owner/sbox/test/pandas_sqlite_dbase]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
答案 0 :(得分:1)
我要检查的是〜实际是什么(似乎您的概念不好)通常是主目录,因此,对于用户来说,您的“用户/所有者”,这就是为什么要获得“用户/所有者/用户/所有者”的原因
要对此进行检查,您可以
$>cd ~
$>pwd