Html Table 数据正在返回 "None"

Html Table data is returning "None"

我正在使用 selenium webdriver 从这个 http://proxydb.net/?protocol=socks4&country=BD 中抓取代理地址。但是在尝试从 table 抓取数据时,我得到了 "None" 。这是我的代码::

from selenium import webdriver

browser = webdriver.Chrome()
browser.get(
    'http://proxydb.net/?protocol=socks4&country=BD')
String = browser.find_element_by_xpath("//table/tbody/tr[1]/td[1]")
print(String.get_attribute('text'))
browser.quit()

这是输出:

C:\Users\Asus\Documents\Hello World>python -u "c:\Users\Asus\Documents\Hello World\Web Scraping\proxy\proxy1.py"

DevTools listening on ws://127.0.0.1:56478/devtools/browser/215c65c4-d3c5-4653-85c1-1f63ccde50ba
[36844:7508:0115/050206.852:ERROR:device_event_log_impl.cc(211)] [05:02:06.852] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[36844:7508:0115/050206.854:ERROR:device_event_log_impl.cc(211)] [05:02:06.854] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[36844:7508:0115/050206.870:ERROR:device_event_log_impl.cc(211)] [05:02:06.869] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
None

在这里,为什么我得到这个 [36844:7508:0115/050206.852:ERROR:device_event_log_impl.cc(211)] [05:02:06.852] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F) ? 以及如何解决这个“None”问题?

如果你想要一个元素的文本。首先等待元素加载,然后打印它的文本。

wait = WebDriverWait(browser,10)
elem = wait.until(EC.presence_of_element_located((By.XPATH,"//table/tbody/tr[1]/td[1]")))
print(elem.text)

产出

203.188.245.98:52837

导入

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC