InvalidSelectorError: Compound class names not permitted报错处理

环境:python3.6 + selenium 3.11 +  chromedriver.exe

我们在解析网页的时候,总是会遇到大量的tag,如何精确定位到这些tag,也是有很多的方法。

今天在用 find_element_by_class_name获取一个节点对象时,报了个错 Compound class names not permitted.

原始代码:

selected_div = driver.find_element_by_class_name('next-pagination next-pagination-normal next-pagination-medium medium pagination')

修改后的代码:

selected_div = driver.find_element_by_css_selector("[class='next-pagination next-pagination-normal next-pagination-medium medium pagination']")

或者:

selected_div = driver.find_element_by_css_selector(".next-pagination.next-pagination-normal.next-pagination-medium.medium.pagination")

这两段代码都可以正常获取到所需对象。

总结:

在获取包含多个class名称的tag对象时

建议使用:

find_element_by_css_selector(".xx.xxx.xxxxx")

或者

find_element_by_css_selector("[class='xx xxx xxxxx']")

InvalidSelectorError: Compound class names not permitted报错处理的更多相关文章

  1. selenium的报错信息:selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Compound class names not permitted

    报错信息:selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Compound class ...

  2. ffmpeg Operation not permitted 报错的解决过程记录

    问题重现 由于视频的录制过程出现了一些小问题,需要重新将视频文件切割和合并,找了几个视频编辑软件来做这个事情,最终的结果都不是特别满意,当时已经挺晚的了,本来打算上床睡觉第二天再去想辙,从椅子上起身的 ...

  3. selenium实战-Compound class names not permitted

    这个复合类其实就是嵌套类,使用最后一个作为类名即可

  4. Nginx报错: "Too many open files accept" 和 "could not build the server_names_hash"

    一.访问Nginx时,报错:"accept() failed (24: Too many open files)"原因时:nginx的连接数超过了系统设定的最大值造成的. 处理办法 ...

  5. docker—tomcat 报错:Failed to get D-Bus connection: Operation not permitted

    docker search centos   查系统镜像 docker pull docker.io/centos 进入容器 [root@git opt]# docker images REPOSIT ...

  6. 使用npm install报错-4048 operation not permitted解决

    刚刚使用npm install时一直报错-4048 operation not permitted,也尝试了多种方法,终于使问题得到解决,这里总结几种方法,先贴图: 一:权限问题 首先看到operat ...

  7. 巨坑npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build/css/add.p

    Windows10环境 npm run dev 报错  终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build ...

  8. Android版本28使用http请求报错not permitted by network security policy

    Android版本28使用http请求报错not permitted by network security policy android模拟器调试登录的时候报错 CLEARTEXT communic ...

  9. 启动servlet报错:The servlets named [DemoServlet] and [main.java.com.wlf.demo.servlet.DemoServlet] are both mapped to the url-pattern [/hello] which is not permitted

    先看具体错误日志: [2019-04-26 09:29:25,484] Artifact demo-servlet:war: Artifact is being deployed, please wa ...

随机推荐

  1. DoNetCore Web Api 采用Swagger进行接口文档管理

    第一步:创建API项目 步骤这里不说明 第二步:就是Nuget 包, 两种方式:1.工具->Nuget管理->程序包管理控制台 Install-Package Swashbuckle.As ...

  2. SpringBoot集成MyBatis的分页插件PageHelper--详细步骤

    1.pom中添加依赖包 <!--pageHelper基本依赖 --> <dependency> <groupId>com.github.pagehelper< ...

  3. React: JSX生成真实DOM结点

    在上一篇文章中,我们介绍了 Babel 是如何将 JSX 代码编译成可执行代码的,随后也实现了一个自己的解析器,模拟了 Babel 编译的过程. 现在我们再来回顾一下,假定有如下业务代码: const ...

  4. C#中多集合组合实现

    C#中多集合组合使用方法,主要用到 Enumerable.Join方法 var skuInfoList = new Dictionary<int, List<long>>(); ...

  5. Navicat Premium 12破解激活11

    下载Navicat Premium 12并安装: 百度云下载:Navicat Premium 12注册机   链接:https://pan.baidu.com/s/1UcA5yXjtdfXlBZI-2 ...

  6. 使用js对社会信用代码进行正则验证

    注:参考了该博客(https://blog.csdn.net/qq_37142340/article/details/80695187)进行了一些修改,本文验证使用在微信小程序上. 直接贴代码: va ...

  7. Python常用标准库函数

    math库: >>> import math >>> dir(math) ['__doc__', '__loader__', '__name__', '__pack ...

  8. python 中的tile函数,shape函数,sum函数

    1.tile函数: tile函数是模板numpy.lib.shape_base中的函数.函数的形式是tile(A,reps) A的类型几乎所有类型都可以:array, list, tuple, dic ...

  9. c++中关联容器map的使用

    C++关联容器<map>简单总结(转) 补充: 使用count,返回的是被查找元素的个数.如果有,返回1:否则,返回0.注意,map中不存在相同元素,所以返回值只能是1或0. 使用find ...

  10. 2-ESP8266 SDK开发基础入门篇--非RTOS版与RTOS版

    https://www.cnblogs.com/yangfengwu/p/11071580.html 所有的源码 https://gitee.com/yang456/Learn8266SDKDevel ...