当前位置:网站首页>urllib.parse 解析url连接中的参数
urllib.parse 解析url连接中的参数
2022-06-28 23:21:00 【supramolecular】
from urllib.parse import urlparse, parse_qs,unquote
urldata = "'https://zhidao.baidu.com/search?lm=0&rn=10&pn=0&fr=search&ie=gbk&word=%C8%AB%CD%F8%D3%AA%CF%FA'"
urldata = unquote(urldata, encoding='gbk', errors='replace')
result = urlparse(urldata)
print(result)
print(parse_qs(result.query))
keyword = parse_qs(result.query)['word'][0]
print(keyword)结果
ParseResult(scheme='', netloc='', path="'https://zhidao.baidu.com/search", params='', query="lm=0&rn=10&pn=0&fr=search&ie=gbk&word=全网营销'", fragment='')
{'lm': ['0'], 'rn': ['10'], 'pn': ['0'], 'fr': ['search'], 'ie': ['gbk'], 'word': ["全网营销'"]}
全网营销'
边栏推荐
- Thinking about lever
- 2022-06-28: what does the following golang code output? A:true; B:false; C:panic; D: Compilation failed. package main import “fm
- 复杂嵌套的对象池(4)——管理多类实例和多阶段实例的对象池
- 【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
- 2022-06-28:以下golang代码输出什么?A:true;B:false;C:panic;D:编译失败。 package main import “fm
- ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql
- Master the usage of const
- ROS2中的行为树 BehaviorTree
- Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding
- 一张能卖上千万,商家扩张比玩家还快:球星卡的江湖你不懂
猜你喜欢
![[matlab]函数定义与使用](/img/43/a7970ca8e075151277f7773434f7db.png)
[matlab]函数定义与使用

lock4j--分布式锁中间件--使用/实例

关联线探究,如何连接流程图的两个节点

【狀態機設計】Moore、Mealy狀態機、三段式、二段式、一段式狀態機書寫規範

2022 PMP project management examination agile knowledge points (4)

Encounter with avita 11: long lost freshness under strong product power

Production environment sonarqube installation

Web API learning notes 1

Linq连表查询

IDC: Alibaba cloud ranks first in the market share of China's data governance platform in 2021
随机推荐
小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
Web API learning notes 1
非科班!自学之路!
VSCode里使用条件断点(基于GDB)
移动端异构运算技术 - GPU OpenCL 编程(基础篇)
SqlServer复习
Cmake tutorial (I)
The picture display on the left of the two column layout is determined by the content height on the right
Form verification problem - El select (solution to automatically trigger verification on initialization page)
With a monthly salary of 60000 yuan, such people began to be robbed after the Internet "reduced costs and increased efficiency"
Hit the industry directly | the flying propeller launched the industry's first model selection tool
Is the account opening of Guosheng securities really safe and reliable
TDD和自动化测试
复杂嵌套的对象池(4)——管理多类实例和多阶段实例的对象池
【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
计数排序和排序的稳定性
Undefined symbol main (referred from entry9a.o).
关联线探究,如何连接流程图的两个节点
Prometeus 2.36.0 new features
收藏 | VLOOKUP函数的这些妙用你都知道吗?