python与硒库的Webscraping错误
我尝试使用Selenium库来提取下面的数据,但不幸的是,我得到了下一个错误。有人可以帮助我吗?
从Selenium Import WebDriver中,
url = 'https://www150.statcan.gc.ca/n1/pub/71-607-x/2021004/exp-eng.htm?r1=(1)&r2=0&r3=0&r4=12&r5=0&r7=0&r8=2022-02-01&r9=2022-02-011'
driver = webdriver.Chrome()
driver.get(url)
table = driver.find_elements_by_class_name('data')
for table1 in table:
value = table1.find_element_by_xpath('.//*[@id="report_table"]/tbody/tr[1]/td[6]').text
quantity = table1.find_element_by_xpath('.//*[@id="report_table"]/tbody/tr[1]/td[7]').text
unit = table1.find_element_by_xpath('.//*[@id="report_table"]/tbody/tr[1]/td[8]').text
print(value, quantity, quantity)
错误是:
enter image description herePS C:\Users\asus\Desktop\home> [840:7000:0417/201023.654:ERROR:device_event_log_impl.cc(214)] [20:10:23.656] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:7000:0417/201023.654:ERROR:device_event_log_impl.cc(214)] [20:10:23.658] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:7000:0417/201023.654:ERROR:device_event_log_impl.cc(214)] [20:10:23.659] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:7000:0417/201023.659:ERROR:device_event_log_impl.cc(214)] [20:10:23.660] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:16136:0417/201113.924:ERROR:util.cc(126)] Can't create base directory: C:\Program Files\Google\GoogleUpdater
I tried to extract data the site below with selenium library but Unfortunately I got next error. is there anyone who can help me??
from selenium import webdriver
url = 'https://www150.statcan.gc.ca/n1/pub/71-607-x/2021004/exp-eng.htm?r1=(1)&r2=0&r3=0&r4=12&r5=0&r7=0&r8=2022-02-01&r9=2022-02-011'
driver = webdriver.Chrome()
driver.get(url)
table = driver.find_elements_by_class_name('data')
for table1 in table:
value = table1.find_element_by_xpath('.//*[@id="report_table"]/tbody/tr[1]/td[6]').text
quantity = table1.find_element_by_xpath('.//*[@id="report_table"]/tbody/tr[1]/td[7]').text
unit = table1.find_element_by_xpath('.//*[@id="report_table"]/tbody/tr[1]/td[8]').text
print(value, quantity, quantity)
the Error is:
enter image description herePS C:\Users\asus\Desktop\home> [840:7000:0417/201023.654:ERROR:device_event_log_impl.cc(214)] [20:10:23.656] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:7000:0417/201023.654:ERROR:device_event_log_impl.cc(214)] [20:10:23.658] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:7000:0417/201023.654:ERROR:device_event_log_impl.cc(214)] [20:10:23.659] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:7000:0417/201023.659:ERROR:device_event_log_impl.cc(214)] [20:10:23.660] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[840:16136:0417/201113.924:ERROR:util.cc(126)] Can't create base directory: C:\Program Files\Google\GoogleUpdater
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需手动创建目录:
“ c:\ program Files \ Google \ Googleupdater ”。
应该正常工作。
Just create the directory manually:
"C:\Program Files\Google\GoogleUpdater".
Should work properly.
我认为,如果您还没有
I think you should link to your webDriver using its path if you haven't already