基础属性:

代码:

import keyword
import requests
r = requests.get("http://www.baidu.com")
r.encoding = 'utf-8'
print('//网页字符串形式\n')
print(r.text)
print('//200--成功\n')
print(r.status_code)
print('//从HTTP的header中猜测响应内容的编码方式\n')
print(r.encoding)
print('//从内容中分析出响应内容的编码方式-备选编码方式\n')
print(r.apparent_encoding)
print('//HTTP响应内容的二进制形式\n')
print(r.content)
print('\n')

结果:

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============= RESTART: C:\Users\HWP\Desktop\crawler_test\no.1.py =============
//网页字符串形式<!DOCTYPE html><!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>//200--成功200
//从HTTP的header中猜测响应内容的编码方式utf-8
//从内容中分析出响应内容的编码方式-备选编码方式utf-8
//HTTP响应内容的二进制形式b'<!DOCTYPE html>\r\n<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>\xe7\x99\xbe\xe5\xba\xa6\xe4\xb8\x80\xe4\xb8\x8b\xef\xbc\x8c\xe4\xbd\xa0\xe5\xb0\xb1\xe7\x9f\xa5\xe9\x81\x93</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=\xe7\x99\xbe\xe5\xba\xa6\xe4\xb8\x80\xe4\xb8\x8b class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>\xe6\x96\xb0\xe9\x97\xbb</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>\xe5\x9c\xb0\xe5\x9b\xbe</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>\xe8\xa7\x86\xe9\xa2\x91</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>\xe8\xb4\xb4\xe5\x90\xa7</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>\xe7\x99\xbb\xe5\xbd\x95</a> </noscript> <script>document.write(\'<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=\'+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ \'" name="tj_login" class="lb">\xe7\x99\xbb\xe5\xbd\x95</a>\');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">\xe6\x9b\xb4\xe5\xa4\x9a\xe4\xba\xa7\xe5\x93\x81</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>\xe5\x85\xb3\xe4\xba\x8e\xe7\x99\xbe\xe5\xba\xa6</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>\xe4\xbd\xbf\xe7\x94\xa8\xe7\x99\xbe\xe5\xba\xa6\xe5\x89\x8d\xe5\xbf\x85\xe8\xaf\xbb</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>\xe6\x84\x8f\xe8\xa7\x81\xe5\x8f\x8d\xe9\xa6\x88</a>&nbsp;\xe4\xba\xacICP\xe8\xaf\x81030173\xe5\x8f\xb7&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>\r\n'>>> 

截图:

爬虫基础-request的一些基础属性相关推荐

  1. 搜狗词库爬虫(2):基础爬虫框架的运行流程

    系列目录: 搜狗词库爬虫(1):基础爬虫架构和爬取词库分类 项目Github地址:github.com/padluo/sogo- 各模块对应的内容如下: getCategory.py,提取词库分类ID ...

  2. 语法基础(三. 类,属性,方法,方法重载,方法重写,构造方法,访问修饰符)

    语法基础(三. 类,属性,方法,方法重载,方法重写,构造方法,访问修饰符) (如有错误,欢迎指正,感谢!) 类 类是面向对象的程序设计中的概念,实现信息的封装 概念: 类就是拥有相等行为和相同的属性的 ...

  3. Python3 Requests+BS4网络爬虫:最详细零基础的获取百度快照链接爬虫教程(思路篇)

    Hello,大家好呀,五一劳动节快乐呀!最近在后台接到一个粉丝的私信说怎么爬取百度快照.正好五一有一段时间休息,咱们就来水一篇文章,顺便来巩固巩固基础的知识. 注意注意!这是思路篇,没有代码!只有思路 ...

  4. day 1-requests基础用法和网页基础学习总结

    day 1-requests基础用法和网页基础 1. requests用法 1.认识爬虫 1)爬虫 用程序自动获取网页数据(可以让数据采集的过程变得简单又高效) 2)爬虫流程: 第一步:获取网络数据( ...

  5. ORACLE ERP开发基础之EBS开发基础

    作者: IT168 JarWang  日期: 2009-05-07 [内容导航] 第1页:开发工具安装 第2页:增加数据块 第3页:注册表单FORM 第4页:注册请求 第5页:注册职责 第6页:注册值 ...

  6. python+pytest接口自动化-接口测试基础,http协议基础(一)

    目录 前言: [文章末尾给大家留下了大量的福利] 接口定义 接口分类 常见接口 测试分层 测试左移和右移 总结 HTTP协议简介 HTTP协议特点 HTTP接口请求方法 HTTP与HTTPS区别[重点 ...

  7. 2012级计算机应用基础,2012年计算机应用基础

    2012年计算机应用基础 (42页) 本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦! 29.9 积分 2012年计算机应用基础第一章 计算机基础知识判断:1.C ...

  8. Java基础教程:反射基础

    Java基础教程:反射基础 引入反射 反射是什么 能够动态分析类能力的程序称为反射. 反射是一种很强大且复杂的机制. Class类 在程序运行期间,Java运行时系统始终为所有对象维护一个被称为运行时 ...

  9. java 反射基础_Java基础教程:反射基础

    Java基础教程:反射基础 引入反射 反射是什么 能够动态分析类能力的程序称为反射.反射是一种很强大且复杂的机制. Class类 在程序运行期间,Java运行时系统始终为所有对象维护一个被称为运行时的 ...

最新文章

  1. linux版_巧用linux版powershell,管理linux下的docker
  2. 转载: Web 研发模式演变
  3. Java对象克隆方法(浅克隆、深克隆)
  4. js实现替换指定字符后面的内容(包括指定字符)
  5. leetcode718. 最长重复子数组
  6. windows打开的winform当前焦点 是否是hwnd_推介几款 windows 下非常好用的工具
  7. 用python编写一个汉诺塔的移动函数_关于python递归函数实现汉诺塔
  8. java实现红包要多少钱_Java实现抢红包功能
  9. 团队建立伊始的混沌状态(Thinking in CTO)
  10. CAPL可以读写的几种文件
  11. Windows 下OpenGL的基本安装与配置(基于Visual Studio 2019 与 MinGW)
  12. VSTOhowtoreferene.Net3.5(VSTO如何引用.NET3.5的外接程序)
  13. OpenStack基金会更名,开源基础设施开启新十年
  14. python3调用谷歌翻译_使用python3调用谷歌翻译成中文
  15. poi读取excel教程
  16. 理解AMQP协议和RabbitMQ的性能和可靠平衡
  17. 让独居的父母,时刻受到保护,老人远程无线监护解决方案
  18. Win10重装的方法?一键重装Win10的图文版教程
  19. Python分布式爬虫原理
  20. 接口自动化——one

热门文章

  1. 认知智能,AI的下一个十年 | AI Procon 2020
  2. 率清华团队研发“天机芯”登《Nature》封面,他说类脑计算是发展人工通用智能的基石...
  3. TensorFlow支持Unicode,中文NLP终于省心了
  4. 800万中文词,腾讯AI Lab开源大规模NLP数据集
  5. JMH 和 Arthas 定位问题的案例分享 !
  6. Linux下日志文件过大解决方案
  7. 漫画:什么是 HTTPS 协议?
  8. 源码解析Spring Cloud Zuul
  9. 线性矩阵不等式LMI的运用与Lipschitz非线性系统观测器的设计
  10. 阿里云高级工程师认证机会!