简体   繁体   English

如何使用 Selenium 从网站上抓取文本

[英]How do I scrape text from a website using Selenium

How do I scrape text from a website using Selenium?如何使用 Selenium 从网站上抓取文本? I need to get an inner text from a website.我需要从网站获取内部文本。 I'm using the newest Python and Selenium, all up to date.我使用的是最新的 Python 和 Selenium,都是最新的。 I also have pyautogui.我也有pyautogui。

Here is what I need to scrape:这是我需要刮的:

<span  class="ng-binding" ng-bind-html="addKeysInMatch(characterMatch.bad)">Gorgeous Geodes Glowed</span>

I don't know part of the text though, the "Gorgeous Geodes Glowed" is what I don't know, and I need to find that.不过,我不知道部分文字,“Gorgeous Geodes Glowed”是我不知道的,我需要找到它。

Thanks in advance.提前致谢。

titles_element = driver.find_elements_by_xpath("//span[@class='ng-binding']")
titles = [x.text for x in titles_element]
titles = []
for x in titles_element:
    titles.append(x.text)
print(titles)

The Gorgeous Geodes Glowed is the text that appears after the span class is Identified. Gorgeous Geodes Glowed 是在span类被Identified后出现的文字。 So every time this class appears it will print out the following text.所以每次这个类出现时都会打印出下面的文字。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用selenium python在网站中删除::之前的元素 - How do I scrape ::before element in a website using selenium python 如何在 python 中使用 selenium 从网站上抓取多个图像并将它们保存在特定文件夹中? - How do I scrape multiple images from a website and save them on a specific folder using selenium in python? 如何使用 selenium 从网站抓取数据 - How to scrape data from website using selenium 如何<span id>使用 Python、Selenium 和 BeautifulSoup</span>从 HTML 中抓取此文本<span id>?</span> - How do I scrape this text from an HTML <span id> using Python, Selenium, and BeautifulSoup? 我如何刮一个<li>来自使用 BeautifulSoup 的电子商务网站?</li> - How do i scrape a <li> from a eCom website using BeautifulSoup? 我如何使用scrapy和splash从这个网站上抓取? - How do I scrape from this website using scrapy and splash? 如何使用 python Selenium 滚动抓取动态加载网站 - How do I scrape dynamically loading website with scrolling using python Selenium 如何从我使用硒从网站上提取的文本中删除带有我们想要的单词的元素? - How do I remove the element with the word we want from the text I pulled from a website using selenium? 如何使用硒从网站上抓取一些链接 - How to scrape some links from a website using selenium 如何在python中使用硒和beautifulsoup从网站上抓报纸? - How to scrape newspaper articles from website using selenium and beautifulsoup in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM