当前位置:网站首页>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': ["全网营销'"]}
全网营销'
边栏推荐
- Small sample sharp weapon 2 Text confrontation + semi supervised FGSM & VAT & FGM code implementation
- ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql
- VSCode里使用条件断点(基于GDB)
- [state machine design] Moore, Mealy state machine, three-stage, two-stage and one-stage state machine writing specification
- [conception de la machine d'état] Moore, Mealy State Machine, Three - stage, Two - stage, one - stage State Machine Writing Specification
- 论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
- [stm32 Hal library] serial port communication
- YuMinHong set up two funds funded by his hometown
- Is it safe to open a stock account online?
- Chapter V virtual memory exercise
猜你喜欢

Deep virtual memory (VM)
![LeetCode 324 擺動排序 II[排序 雙指針] HERODING的LeetCode之路](/img/41/b8ba8d771b7224eac1cc8c54fe9d29.png)
LeetCode 324 擺動排序 II[排序 雙指針] HERODING的LeetCode之路
![[API packet capturing in selenium automation] installation and configuration of browsermobproxy](/img/67/3e15b2191ee23a8c4453aad007651d.png)
[API packet capturing in selenium automation] installation and configuration of browsermobproxy

Use conditional breakpoints in vscode (based on GDB)

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

第二章 经典同步练习作业

Master the usage of const

【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
![[数学建模]Matlab非线性规划之fmincon()函数](/img/fc/46949679859b1369fcc83d0d8b637c.png)
[数学建模]Matlab非线性规划之fmincon()函数

再次上榜!知道创宇入选2022中国网安产业竞争力50强
随机推荐
Class extension and optional type extension of dart
笔记
See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections
机器学习6-决策树
Go language - reflect
Langage C - analyse des mots
第三章 处理机调度练习
Is the account opening of Guosheng securities really safe and reliable
全面掌握const的用法《一》
Powerful open source API interface visual management platform Yapi
Leetcode 324 Swing sort II [tri double pointeur] le chemin du leetcode pour l'héroding
机器学习4-降维技术
Use conditional breakpoints in vscode (based on GDB)
Design e-commerce seckill system
O & M troubleshooting - use hcache plug-in to troubleshoot excessive buffer/cache occupancy
运维排查-使用hcache插件排查Buffer/cache占用过高
Flutter obtains the coordinate size of any element in the interface through globalkey
【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范
Chapter IV memory management exercise
[stm32 HAL库] 串口通信