V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
j0shfan
V2EX  ›  Python

Selenium 爬网页的问题, css selector

  •  
  •   j0shfan · Aug 11, 2020 · 2371 views
    This topic created in 2087 days ago, the information mentioned may be changed or developed.
    大佬们,我想爬个网页练练手,现在碰到问题了,目标无法被 CSS 选择器选中,麻烦看下问题出在哪里
    网页是这样的
    <ul>
    <type=1><start=1>
    <li><a href="Papers/XXX.pdf">Preface</a></li>
    <li><a href="Papers/XXX.pdf">Chapter 1</a></li>

    使用 find_element_by_css_selector 可以选中到 ul 这里
    但是再往下 type=1 start=1 怎样都无法选中( ul > type=1 > start=1 )
    想问下问题出在哪里
    6 replies    2020-08-11 21:55:50 +08:00
    yejianmail
        1
    yejianmail  
       Aug 11, 2020 via Android
    不行就试试 xpath 选择器吧
    jeeyong
        2
    jeeyong  
       Aug 11, 2020
    type=1 这个不是元素就是个空标签 属性是 type 值=1
    你非得选这个
    试试 find
    j0shfan
        3
    j0shfan  
    OP
       Aug 11, 2020
    @yejianmail 一样选不中,捂脸
    j0shfan
        4
    j0shfan  
    OP
       Aug 11, 2020
    @jeeyong 实际我想批量选的是 a href 后面那个文件的连接。
    请问 find 是个什么概念,是 find_element(s)吗
    tikazyq
        5
    tikazyq  
       Aug 11, 2020
    用 puppeteer,直接 js 操作,比 selenium 简单很多
    jeeyong
        6
    jeeyong  
       Aug 11, 2020
    不是...之前回复的时候再打 pubg...
    你这<type=1>是什么标签啊?
    没有这种标签啊...这个根本写错了吧..
    还是你爬取的场景遇到这种情况了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3786 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 10:30 · PVG 18:30 · LAX 03:30 · JFK 06:30
    ♥ Do have faith in what you're doing.