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

爬虫获取网站源码时, p 标签总是只能获取到最后一段内容

  •  
  •   dalezyf897 · Mar 18, 2020 · 2542 views
    This topic created in 2389 days ago, the information mentioned may be changed or developed.

    网站源码:

    <p class="profile">
                        
                            江苏省产业技术研究院智能液晶技术研究所(智能液晶所)是一个新型的、以企业方式运营的专业技术研究所,其运营实体为江苏集萃智能液晶科技有限公司。
    <br/>    公司成立于 2016 年 5 月,大楼总面积达 13363.6 平...<span class="profile-open">展开+</span>
                        
                    </p>
    

    crawler.py

    r = requests.get(url, headers=kv)
    print(r.text)
    

    Output

    <p class="profile">
                        
    <br/>    公司成立于 2016 年 5 月,大楼总面积达 13363.6 平...<span class="profile-open">展开+</span>
                        
                    </p>
    

    正在做毕设,求大佬解惑

    lozzow
        1
    lozzow  
       Mar 18, 2020 via iPhone
    不同地方加载的吧,你从浏览器上看到的是加载之后的数据,所以是不一样的
    l3n641
        2
    l3n641  
       Mar 18, 2020
    建议给出 url 地址吧.情况很多种
    第一种是没有获取到的数据,是通过 ajax 获取或者保存到某个变量里面,然后在渲染的.第二种是有防爬虫,识别出了,你是爬虫,所以传递了不完整的数据.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2324 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 03:19 · PVG 11:19 · LAX 20:19 · JFK 23:19
    ♥ Do have faith in what you're doing.