【python 爬虫】python中url链接编码处理方法
来源:互联网 发布:tensorflow spyder 编辑:程序博客网 时间:2024/05/18 13:30
一、问题描述
有些网址,会把中文编码成gb2312格式,例如百度知道,美容这一词,网址上面会编码成:
%C3%C0%C8%DD
那么如何生成这种编码呢?
二、解决方法
1、把要编码的文字encode成所需格式
2、利用urllib 库的quote方法编码
# -*- coding:utf-8*-import sysreload(sys)sys.setdefaultencoding('utf-8')key=str("美容").decode('utf-8').encode('gb2312')import urllibm1=urllib.quote(key)print m1
D:\Python27\python.exe F:/PycharmProjects/url编码.py%C3%C0%C8%DDProcess finished with exit code 0
阅读全文
1 0
- 【python 爬虫】python中url链接编码处理方法
- python url链接编码问题
- python爬虫中对含中文的url处理
- 怎样处理python爬虫中有中文的url
- python处理浏览器URL编码
- python爬虫,抓取百度指定内容的url链接
- Python 爬虫APP URL
- python链接爬虫案例
- Python 链接爬虫
- python中url中解码和编码
- python爬虫常见异常及处理方法
- python中读写文件及中文编码处理方法
- python中读写文件及中文编码处理方法
- python中读写文件及中文编码处理方法【整理】
- python url编码,解码
- python url编码
- python的url编码
- python爬虫-异常处理
- 开发服务器
- hdu_2188
- 机器学习中的相似性度量
- MapReduce优化
- 稀疏编码(Sparse Coding)的前世今生(一)
- 【python 爬虫】python中url链接编码处理方法
- [js高手之路]使用原型对象(prototype)需要注意的地方
- 支持向量机
- mac生成core文件和生成位置
- 最小树形图
- LA 5009
- cmd 高级用法
- app UI自动化框架改进----使用pa设计模式抽离页面元素
- java编程:无序整数序列,求连续子串最大和问题