推荐学习书目
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
omg21
V2EX  ›  Python

soup 对象怎么判断有没有内容?

  •  
  •   omg21 · Jul 11, 2016 · 2177 views
    This topic created in 3603 days ago, the information mentioned may be changed or developed.
    soup = BeautifulSoup(html,'lxml')
    我用 lxml 经常会有不能解析的网页(而且不能解析的时候什么显示都没有),必须用 html.parser 才行, lxml 效率高,不能不用。
    我现在想做个判断,如果 lxml 不能解析就用 html.parser ,
    可是这个 soup 应该怎么判断?不能解析的时候 soup 即不是 None ,也不是""
    1 replies    2016-07-12 10:35:15 +08:00
    practicer
        1
    practicer  
       Jul 12, 2016
    bs 解析返回空值的原因有很多,不提供详细信息不好找原因,最好把目标网址发上来才好分析
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2469 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 01:08 · PVG 09:08 · LAX 18:08 · JFK 21:08
    ♥ Do have faith in what you're doing.