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

求助:beautifulsoup中怎么查找变量

  •  
  •   fyl00 · Sep 8, 2013 · 3311 views
    This topic created in 4701 days ago, the information mentioned may be changed or developed.
    用BS4做了个小爬虫,想爬取不同贴吧的签到数
    所以建立了一个list ,A
    然后通过for循环,对A中不同的贴吧进行抓取
    贴吧的主页链接定义成 home_link='http://tieba.baidu.com/f?kw='+a

    签到数要在这个页面(http://tieba.baidu.com/sign/index?kw=eminem#current_forum )中抓取
    所以写了下面一行代码
    soup.find('a',href="http://tieba.baidu.com/f?kw=eminem")

    怎么把这个href的值用home_link来表达呢

    因为楼主是新人,不知道有没有表达清楚
    1 replies    1970-01-01 08:00:00 +08:00
    manoon
        1
    manoon  
       Sep 8, 2013
    直接soup.find('a',href=home_link)
    不行么?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1130 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 18:10 · PVG 02:10 · LAX 11:10 · JFK 14:10
    ♥ Do have faith in what you're doing.