当前位置:网站首页>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': ["全网营销'"]}
全网营销'
边栏推荐
- [word Tutorial Series Part 1] how to remove arrows in word tables
- 自动化测试的生命周期是什么?
- Lost in cloud computing
- 在QT进行cin(全网最清晰教程)
- Mathematical knowledge: finding combinatorial number I - finding combinatorial number
- Oil monkey script learning
- Hesitating root sound
- 油猴脚本学习
- 【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
- The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
猜你喜欢

C# 面试题目_20220627记录一下

全面掌握const的用法《一》
![[stm32 Hal library] RTC and BKP drives](/img/72/c2c46377d0a2a5a032802640ca0201.png)
[stm32 Hal library] RTC and BKP drives

The picture display on the left of the two column layout is determined by the content height on the right

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

Cmake tutorial (I)

10. Standard i/o redirection and pipeline

ROS2中的行为树 BehaviorTree

With a monthly salary of 60000 yuan, such people began to be robbed after the Internet "reduced costs and increased efficiency"

直击产业落地 | 飞桨重磅推出业界首个模型选型工具
随机推荐
[sword finger offer] 50 First character that appears only once
[flutter issues Series title 71] Mutual Conversion between uint8list and Image in flutter
云计算的迷路者
股票开户在网上开通安全吗?
在QT进行cin(全网最清晰教程)
Non scientific class! The road of self-study!
Interpretation of papers (DCN) towards k-means-friendly spaces: simultaneous deep learning and clustering
WEB API学习笔记1
是使用local_setup.bash 还是 setup.bash
Cmake tutorial (I)
Langage C - analyse des mots
LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路
网上注册股票开户很困难么?在线开户是安全么?
在DialogFragment的onStop(完全不可见)时调用dismiss退出界面报错解决办法
keil工程,程序写多后,RTT不能打印
Chapter II Classic synchronous exercises
Is the account opening of Guosheng securities really safe and reliable
Form verification problem - El select (solution to automatically trigger verification on initialization page)
IDC: Alibaba cloud ranks first in the market share of China's data governance platform in 2021
Cs5463 code module analysis (including download link)