# 使用 Requests 发送网络请求
# 1、导入 Requests 模块
import requests
# 2、尝试获取某个网页

# HTTP 请求类型
r = requests.get('https://api.github.com/events')
r = requests.post('http://httpbin.org/post', data = {'key':'value'})
r = requests.put('http://httpbin.org/put', data = {'key':'value'})
r = requests.delete('http://httpbin.org/delete')
r = requests.head('http://httpbin.org/get')
r = requests.options('http://httpbin.org/get')
# 通过打印输出该 URL
r.url

# 服务器相应内容
# 1、读取服务器响应的内容
r.text
# Requests文本编码,能够使用 r.encoding 属性来改变它
r.encoding
# 2、二进制响应内容,以字节的方式访问请求响应体,对于非文本请求
r.content
# 3、JSON 响应内容,内置的 JSON 解码器,助你处理 JSON 数据
r.json()
# 获取来自服务器的原始套接字响应
r.raw

Python爬虫——Request模块的更多相关文章

  1. python爬虫 urllib模块url编码处理

    案例:爬取使用搜狗根据指定词条搜索到的页面数据(例如爬取词条为‘周杰伦'的页面数据) import urllib.request # 1.指定url url = 'https://www.sogou. ...

  2. python 爬虫 urllib模块 目录

    python 爬虫 urllib模块介绍 python 爬虫 urllib模块 url编码处理 python 爬虫 urllib模块 反爬虫机制UA python 爬虫 urllib模块 发起post ...

  3. Python爬虫urllib模块

    Python爬虫练习(urllib模块) 关注公众号"轻松学编程"了解更多. 1.获取百度首页数据 流程:a.设置请求地址 b.设置请求时间 c.获取响应(对响应进行解码) ''' ...

  4. Python之request模块-基础用法

    Request模块参考中文手册:https://requests.readthedocs.io/zh_CN/latest/ Request模块 1.查看pip已装包(模块)的安装信息(模块的路径.版本 ...

  5. python 爬虫 urllib模块 反爬虫机制UA

    方法: 使用urlencode函数 urllib.request.urlopen() import urllib.request import urllib.parse url = 'https:// ...

  6. python 爬虫 urllib模块介绍

    一.urllib库 概念:urllib是Python自带的一个用于爬虫的库,其主要作用就是可以通过代码模拟浏览器发送请求.其常被用到的子模块在Python3中的为urllib.request和urll ...

  7. python爬虫-urllib模块

    urllib 模块是一个高级的 web 交流库,其核心功能就是模仿web浏览器等客户端,去请求相应的资源,并返回一个类文件对象.urllib 支持各种 web 协议,例如:HTTP.FTP.Gophe ...

  8. Python爬虫——selenium模块

    selenium模块介绍 selenium最初是一个测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全模拟浏览 ...

  9. Python爬虫常用模块,BeautifulSoup笔记

    import urllib import urllib.request as request import re from bs4 import * #url = 'http://zh.house.q ...

随机推荐

  1. C语言,链表操作

    #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string ...

  2. vue学习好文连接

    1.什么是虚拟dom(VNode)? https://github.com/answershuto/learnVue/blob/master/docs/VNode%E8%8A%82%E7%82%B9. ...

  3. 位运算练习:将整数A转换为B,需要改变多少个bit位

    思路解析: 将整数A转换为B,如果A和B在第i(0<=i<32)个位上相等,则不需要改变这个BIT位,如果在第i位上不相等,则需要改变这个BIT位.所以问题转化为了A和B有多少个BIT位不 ...

  4. 小程序构建npm出现没有找到node_modules

    以下转自:https://blog.csdn.net/zhangyabo_code/article/details/86162671 npm initnpm install --production ...

  5. kubenetes服务发现

    一.基于 iptables 的 Service 实现 Pod的ip地址不是固定了.Service通过selector属性和后端Pod关联,被selector选中的Pod被称为Service的Endpo ...

  6. 将asp.net mvc的aspx视图转化为Razor视图

    ASP.NET MVC2.0的项目如何升级到3.0?? 前言:微软在2009年3月份推出了MVC之后,可以说是发展的速度非常快,仅仅过了不到3年的时间,MVC版本已经从1.0到达4.0,尤其是2.0和 ...

  7. Python实现多线程调用GDAL执行正射校正

    python实现多线程参考http://www.runoob.com/python/python-multithreading.html #!/usr/bin/env python # coding: ...

  8. VS编写一个项目的路径规划

    原文路径:http://blog.csdn.net/puttytree/article/details/7838419 https://www.cnblogs.com/zhehan54/p/45678 ...

  9. JSTL的使用

    使用JSTL前的准备 想要使用JSTL,首先需要给工程导入JSTL的包(JSTL.jar和standard.jar). JSTL标签库 在JSTL中分为以下五个标签 核心标签 格式化标签 SQL标签 ...

  10. 17Linux_mariadb_PXE+Kickstart

    Mariadb mariadb-client mariadb-server # yum groupinstall mariadb mariadb-client mariadb-server -y # ...