1.首先进入目标网站,浏览器查看源码,找到head标签下面的meta标签,一般meta标签不止一个,我们只需找到charset属性里面的值即可

2.requests请求成功时,设置它的编码,代码如下

def get_one(url):
res = requests.get(url)
res.encoding='gb2312' #编码格式
if res.status_code == 200:
return res.text
return None

python使用requests请求的数据乱码的更多相关文章

  1. Python爬虫requests请求库

    requests:pip install  request 安装 实例: import requestsurl = 'http://www.baidu.com'response = requests. ...

  2. python 使用requests 请求 https 接口 ,取消警告waring

    response = requests.request("POST", url, timeout=20, data=payload, headers=headers, proxie ...

  3. python用requests请求,报SSL:CERTIFICATE_VERIFY_FAILED错误。

    response = requests.request("GET", url, headers=headers, params=querystring, verify=False) ...

  4. python发送requests请求时,使用登录的token值,作为下一个接口的请求头信息

    背景介绍: 发送搜索请求时,需要用到登录接口返回值中的token值 代码实现: 登录代码: 搜索接口:

  5. jsonp跨域请求360数据乱码解决办法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  6. python 用requests请求,报SSL:CERTIFICATE_VERIFY_FAILED错误

    https://www.aliyun.com/jiaocheng/437481.html

  7. requests请求获取cookies的字典格式

    python中requests请求的cookies值一般是jar包,如何将cookies值改为字典,此处运用了方法.举例如下: import  requests response = requests ...

  8. Python+requests 发送简单请求--》获取响应状态--》获取请求响应数据

    Python+requests 发送简单请求-->获取响应状态-->获取请求响应数据 1.环境:安装了Python和vscode编译器(Python自带的编译器也ok).fiddler抓包 ...

  9. python使用requests发送application/x-www-form-urlencoded请求数据

    def client_post_formurlencodeddata_requests(request_url,requestJSONdata): #功能说明:发送以form表单数据格式(它要求数据名 ...

随机推荐

  1. Atcoder Grand-014 Writeup

    A - Cookie Exchanges 题面 Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respec ...

  2. WordPaster-dedecms5.7整合教程

    1.1. 与dedecms5.7整合 本教程中提到的插件文件可在官网的php-ckeditor3x示例中找到. 示例:http://www.ncmem.com/download/WordPaster2 ...

  3. django基础操作

    web应用程序:可以通过web访问的应用程序 bs/cs架构 http协议 基于TCP/IP协议之上的应用层协议 基于请求-响应模式:客户端先发送请求,服务端再响应 无状态保存:http协议对于发送的 ...

  4. TypeError: 'MongoClient' object is not callable

    在声明数据库的时候,将中括号[ ]换成了圆括号() 错误:

  5. Forward团队-爬虫豆瓣top250项目-设计文档

    组长地址:http://www.cnblogs.com/mazhuangmz/p/7603594.html 成员:马壮,李志宇,刘子轩,年光宇,邢云淇,张良 设计方案: 1.能分析HTML语言: 2. ...

  6. bzoj3262(cdq分治模板)

    裸的cdq,注意去重: #include<iostream> #include<cstdio> #include<cmath> #include<cstrin ...

  7. 【repost】对JAVASCRIPT匿名函数的理解(透彻版)

    Query片段: view plaincopy to clipboardprint? (function(){ //这里忽略jQuery所有实现 })(); 半年前初次接触jQuery的时候,我也像其 ...

  8. 准备用有人云平台和tlink.io云平台和电脑做云转发

    初步想的是用有人做国网电表转发,用tlink.io做综合采集模块转发,耗时一天 然后用tlink.io的做二次前端开发,耗时两天 用有人做二次前端开发,耗时两天 最后可以试试用常见的OPC公网转发到这 ...

  9. 第四章-shceme和数据类型优化

    选择数据类型的原则: 1.更小通常更好.因为占用更少磁盘,内存和cpu缓存.但是要确保没有低估,因为进行alter时,是很耗时和头疼的操作.所以当无法确定数据类型的时候,选择不会超过范围的最小类型. ...

  10. LCA的 RMQ解法模版

    struct Edge{ int from, to, nex; }edge[N<<1]; int head[N], edgenum; void addedge(int u, int v){ ...