python 进行网址 URL 中的 % 转化

网址URL中,有很多%,很难看出网址中的有用信息,如:get请求中,URL中的参数。通过 python3 的urllib包,可以实现对URL中%的转换。

import urllib.parse
url = "https://vws2019.lqqgis.com/portal/sharing/rest/search?num=100&start=1&sortField=modified&sortOrder=desc&q=%20owner%3A%22arcgis%22%20orgid%3A0123456789ABCDEF%20((type%3A%22Scene%20Service%22%20OR%20type%3A%22Feature%20Collection%22%20OR%20type%3A%22Route%20Layer%22%20OR%20type%3A%22Layer%22%20OR%20type%3A%22Explorer%20Layer%22%20OR%20type%3A%22Tile%20Package%22%20OR%20type%3A%22Compact%20Tile%20Package%22%20OR%20type%3A%22Vector%20Tile%20Package%22%20OR%20type%3A%22Scene%20Package%22%20OR%20type%3A%22Layer%20Package%22%20OR%20type%3A%22Feature%20Service%22%20OR%20type%3A%22Stream%20Service%22%20OR%20type%3A%22Feed%22%20OR%20type%3A%22Map%20Service%22%20OR%20type%3A%22Vector%20Tile%20Service%22%20OR%20type%3A%22Image%20Service%22%20OR%20type%3A%22WMS%22%20OR%20type%3A%22WFS%22%20OR%20type%3A%22WMTS%22%20OR%20type%3A%22KML%22%20OR%20typekeywords%3A%22OGC%22%20OR%20typekeywords%3A%22Geodata%20Service%22%20OR%20type%3A%22Globe%20Service%22%20OR%20type%3A%22CSV%22%20OR%20type%3A%22Shapefile%22%20OR%20type%3A%22GeoJson%22%20OR%20type%3A%22Service%20Definition%22%20OR%20type%3A%22File%20Geodatabase%22%20OR%20type%3A%22CAD%20Drawing%22%20OR%20type%3A%22Relational%20Database%20Connection%22)%20-type%3A(%22Web%20Mapping%20Application%22%20OR%20%22Geodata%20Service%22))%20%20ownerfolder%3A9d0cca432e9544c9b0c0cbfb8d619b99%20-type%3A(%22Code%20Attachment%22%20OR%20%22Featured%20Items%22)%20-typekeywords%3A(%22MapAreaPackage%22)%20-type%3A(%22Map%20Area%22)&categories=&f=json&token=MPt1x_xzciuC0Dmq0ILZjJNvltXXNHiJo75-YdWy8eK50uFOke7cA5K_5lV3iNRw0wHWd1fvxD-SA1C8P1J9OqRW_QteQGNhessZ4DLtRX0_Zk7WcZ0XYPOg-1-TdHyWoJvlwQ6LW4c_EH9HT9i5piLQw1JOX2D7SDJ5VFiNm6eRcug24Wj42MlCGr8-KeHcIHJjiE4GjTKzvxMRuujZQg.."
_de_code= urllib.parse.unquote(url)
print(_de_code)
https://vws2019.lqqgis.com/portal/sharing/rest/search?num=100&start=1&sortField=modified&sortOrder=desc&q= owner:"arcgis" orgid:0123456789ABCDEF ((type:"Scene Service" OR type:"Feature Collection" OR type:"Route Layer" OR type:"Layer" OR type:"Explorer Layer" OR type:"Tile Package" OR type:"Compact Tile Package" OR type:"Vector Tile Package" OR type:"Scene Package" OR type:"Layer Package" OR type:"Feature Service" OR type:"Stream Service" OR type:"Feed" OR type:"Map Service" OR type:"Vector Tile Service" OR type:"Image Service" OR type:"WMS" OR type:"WFS" OR type:"WMTS" OR type:"KML" OR typekeywords:"OGC" OR typekeywords:"Geodata Service" OR type:"Globe Service" OR type:"CSV" OR type:"Shapefile" OR type:"GeoJson" OR type:"Service Definition" OR type:"File Geodatabase" OR type:"CAD Drawing" OR type:"Relational Database Connection") -type:("Web Mapping Application" OR "Geodata Service"))  ownerfolder:9d0cca432e9544c9b0c0cbfb8d619b99 -type:("Code Attachment" OR "Featured Items") -typekeywords:("MapAreaPackage") -type:("Map Area")&categories=&f=json&token=MPt1x_xzciuC0Dmq0ILZjJNvltXXNHiJo75-YdWy8eK50uFOke7cA5K_5lV3iNRw0wHWd1fvxD-SA1C8P1J9OqRW_QteQGNhessZ4DLtRX0_Zk7WcZ0XYPOg-1-TdHyWoJvlwQ6LW4c_EH9HT9i5piLQw1JOX2D7SDJ5VFiNm6eRcug24Wj42MlCGr8-KeHcIHJjiE4GjTKzvxMRuujZQg..

posted @ 2024-03-16 22:03  lqqgis  阅读(142)  评论(0编辑  收藏  举报