我正在编写代码,以便使用Selenium自动计算给定链接的字数。我在driver.get()
中提供了URL。我使用了find_elements_by_xpath
,它将返回一个链接列表。我想做的是爬到每个链接,找到像“机器学习”,“深度学习”等词的频率,并打印在excel表格中的单词频率。你知道吗
我已经提取了链接。我该如何进一步。你知道吗
from selenium import webdriver
import os
driverLocation = "C:\\Users\\Shishir\\workspace\\libs\\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = driverLocation
driver = webdriver.Chrome(driverLocation)
driver.get("https://www.servicenow.com/solutions-by-category.html")
#Get elements by Xpath
links = driver.find_elements_by_xpath("//a[@href]")
for elem in links:
#print all the links
print(elem.get_attribute("href"))
目前没有回答
相关问题 更多 >
编程相关推荐