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

求助:为什么这里要这样写?

  •  
  •   DrPython · Mar 7, 2019 · 1220 views
    This topic created in 2642 days ago, the information mentioned may be changed or developed.
    想获取知乎发现页的问题的答案内容,代码如下:
    import requests
    from pyquery import PyQuery as pq

    url = 'https://www.zhihu.com/explore'
    headers = {
    'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
    }
    html = requests.get(url, headers=headers)

    doc = pq(html.text)
    results = doc('.explore-tab .feed-item').items()
    for item in results:
    answer = pq(item.find('.content').html()).text() #这里为什么直接写 item.find('.content').text()出来的
    内容是夹带符号,而且内容是不完整的。这段代码要怎么理解?

    第一次提问,写的有点乱。
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6116 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 96821589 · 45ms · UTC 03:07 · PVG 11:07 · LAX 20:07 · JFK 23:07
    ♥ Do have faith in what you're doing.