github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/url_parse.en.md (about) 1 ### `url_parse()` {#fn-url-parse} 2 3 Function prototype: `fn url_parse(key)` 4 5 Function description: parse the url whose field name is key. 6 7 Function parameters: 8 9 - `key`: field name of the url to parse. 10 11 Example: 12 13 ```python 14 # Data to be processed: {"url": "https://www.baidu.com"} 15 16 # process script 17 json(_, url) 18 m = url_parse(url) 19 add_key(scheme, m["scheme"]) 20 21 # process result 22 { 23 "url": "https://www.baidu.com", 24 "scheme": "https" 25 } 26 ``` 27 28 The above example extracts its scheme from the url. In addition, it can also extract information such as host, port, path, and Function parameters: carried in the url from the url, as shown in the following example: 29 30 ```python 31 # Data to be processed: {"url": "https://www.google.com/search?q=abc&sclient=gws-wiz"} 32 33 # process script 34 json(_, url) 35 m = url_parse(url) 36 add_key(sclient, m["params"]["sclient"]) # The Function parameters: carried in the url are saved under the params field 37 add_key(h, m["host"]) 38 add_key(path, m["path"]) 39 40 # process result 41 { 42 "url": "https://www.google.com/search?q=abc&sclient=gws-wiz", 43 "h": "www.google.com", 44 "path": "/search", 45 "sclient": "gws-wiz" 46 } 47 ```