我想制作一个可以从Vocabulary.com收集单词的机器人,我不知道如何从页面中获取文本,然后将其作为变量存储在python 2.7中。这就是我现在所拥有的。
import os
import time
from selenium import webdriver
chromedriver = "C:\Users\Owner\Desktop\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
browser = webdriver.Chrome(chromedriver)
browser.get("https://www.vocabulary.com/dictionary/raise#")
Word1 = browser.find_element_by_class_name('dynamictext')
请跟我说,因为我对编程很新,这是我的第一篇文章。
我不知道应该从inspect元素中复制什么,所以我要过去所有内容。
//*[@id="dictionaryContent"]/div/h1
#dictionaryContent > div > h1
<h1 class="dynamictext">raise<a data-audio="R/13JE699JC2AJ8" class="audio"></a></h1>
先谢谢。