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

爬虫 session.get(url,headers) 和 resquest.get(url,heasers) 有什么区别呀

  •  
  •   yxlbeyond · Dec 1, 2017 · 4630 views
    This topic created in 3229 days ago, the information mentioned may be changed or developed.
    import requests
    # 实例化 session
    session = request.session()
    response = session.get(url,headers)


    # 直接是使用
    response = requests.get(url,headers)

    这两者有什么区别呀???
    chen6366005
        1
    chen6366005  
       Dec 1, 2017
    前者会记录 session,后者不会。
    yearliny
        2
    yearliny  
       Dec 1, 2017 via Android
    看过文档了吗?最显像的特征就是能保留 cookie,对同一个主机的请求可以复用 TCP 连接从而提升速度。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2188 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:29 · PVG 12:29 · LAX 21:29 · JFK 00:29
    ♥ Do have faith in what you're doing.