python - 当 div 类的名称临时更改时,使用 selenium 查找网站的某些部分
问题描述
我正在尝试抓取一个网站,但它使用某种软件来更改 div 的类名称。因为我使用的技术是find_elements_by_xpath("//div[@class='classname']")
每次 div 类名更改我的解决方案失败时。我感兴趣的网站部分如下所示:
<div class="classname1"> #List of items start
<div class="classname2"> #I want it (this is special cause its like the title)
</div>
<div class="classname3"> # the first item (i want it cause the divs inside it is the information of the item
<div class = "classname4">
</div>
...
more <div class> inside
</div>
<div class="classname3"> #second item I am also interested in(same as the first one, i want it cause the divs inside it is the information of the item)
<div class="classname5">
</div>
...
more <div class> inside
</div>
# and so on
...
</div>
是否有另一种方法来本地化这些项目但避免这个问题?
解决方案
推荐阅读
- docker - 使用 Docker 构建返回 HashSum 错误
- swift - Swift:如何将 AnyObject.Type 作为参数?
- php - 相同的角色对不同的用户有不同的操作
- python - 提取二维数组中最小点的索引
- swift - Swift4:当你有一个导航控制器时如何设置顶部约束?
- node.js - 需要代码在网页上显示 mysql 数据库,其中使用 angular.js 和 node.js 进行分页
- smartcard - 如何检查 ISD/CM 下的哪些密钥是“安全通道基础密钥”?
- javascript - 按 id 匹配 2 个数组(用户 [用户 id 作为键] 到订单 [订单 id 数组的值])
- python - 熊猫。读取 html 写入 csv
- r - 如果特定学习者在特定任务上失败,如何使基准函数不失败?