zoukankan      html  css  js  c++  java
  • python接口自动化测试九:重定向相关

    allow_redirects=False  不重定向

    # 获取重定向后的地址
    loc = r.headers

     

     

     

    # 相对地址
    host = 'https://i.cnblogs.com/'
    url = host+'EditPosts.aspx?opt=1'

    loc = r.headers['Location']
    url1 = host+loc     # 拼接出重定向后的地址

     

     

     

     

    # 追踪重定向过程
    his = r.history
    print(type(his))
    print(his)
    # 追踪第二个请求内容
    r2 = his[1]
    print(r2)

     

    # 通过Response对象,来获取返回内容
    print(r2.url)
    print(r2.status_code)
    print(r2.headers)
    print(r2.test)

     

  • 相关阅读:
    ORM框架
    优酷项目1
    新年第一天
    前端第十天
    前端第九天
    前端第八天
    前端第七天
    前端第六天
    前端第五天
    月亮与六便士
  • 原文地址:https://www.cnblogs.com/zhongyehai/p/9159665.html
Copyright © 2011-2022 走看看