3

Python爬虫编程思想(95):使用Selenium查找单个节点

 2 years ago
source link: https://blog.csdn.net/nokiaguy/article/details/121837358
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python爬虫编程思想(95):使用Selenium查找单个节点

        WebDriver提供了很多API,用来查找单个节点,所谓查找单个节点,也就是不管该页面中包含多少个符合条件的节点,最多只返回第1个符合条件的节点。所有以find_element开头的方法都是用于查找单个节点的API,如图1所示。

        从图1所示的API列表中可以看到,selenium支持通过多种方式查找节点,如XPath、CSS选择器、class属性、id属性、标签名等。这些方法的使用方式基本相同,只是需要传入不同的参数值。

        下面的例子使用selenium通过id属性、name属性和class属性获取表单中特定的input节点,并自动输入表单的内容。

为了演

文章知识点与官方知识档案匹配,可进一步学习相关知识

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK