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. Linux--重要文件

    目录 /etc/resolv.conf /etc/host /etc/sysconfig/network /etc/fstab /etc/rc.local /etc/profile /etc/bash ...

  2. manjaro跳坑记

    why manjaro 有两个原因: 我的电脑上win10+ubuntu16.04,ubuntu上跑一个程序会crash导致重启,不知道如何排查,想换个系统试试.(别人机器上同样G++版本不会cras ...

  3. HotSpot虚拟机的锁优化

    面试中多次被问到synchronized关键字的实现原理,一直认为仅是monitorenter与monitorexit两条指令而已,原来底层涉及到多种锁优化策略,包括:自旋锁,轻量锁,偏向锁. 1.自 ...

  4. Kubernetes网络之Flannel工作原理

    目录 1.Docker网络模式 1.1 bridge网络的构建过程 1.2 外部访问 2.Kubernetes网络模式 2.1 同一个Pod中容器之间的通信 2.2 不同Pod中容器之间的通信 2.3 ...

  5. 移动端初始化常用JavaScript代码

    移动端常用js分享 1.把手机屏幕等分10分(我用的是这种形式),用rem来计算那些需要自适应. <script type="text/javascript"> (fu ...

  6. Java调用Kotlin程序深度解析

    异常: 在之前我们已经学习在Kotlin中的所有异常都是运行期的,而不像Java分为运行期和非运行期,下面用代码来演示一下,先建一个Java的异常: 然后在Kotlin中来调用一下该Java中的方法 ...

  7. unix域套接字

    对于本地通信,unix域套接字通信是internet通信速度的2倍

  8. WIFI信道频率对应

    802.11b/g还是802.11b/g/n 一般都支持13个信道 信道也称作通道(Channel).频段,是以无线信号(电磁波)作为传输载体的数据信号传送通道.无线网络(路由器.AP热点.电脑无线网 ...

  9. shell脚本自动化安装pgsql10.5版本

    看到有个大佬写了个很实用的脚本,于是这里做了转载 #!/bin/bash #进入软件的制定安装目录 echo "进入目录/usr/local,下载pgsql文件" cd /usr/ ...

  10. StringTokenizer字符串分解器

    示例: StringTokenizer st = new StringTokenizer(key, ",", false); while (st.hasMoreTokens()) ...