HIVE的URL解析

目录

从url返回PROTOCOL

从url返回HOST

从url返回PATH

从url返回QUERY

从url返回QUERY中指定的参数的值

从url返回FRAGMENT标识符

从url返回FILE

从url返回AUTHORITY

从url返回USERINFO


 

Every HTTP URL conforms to the syntax of a generic URI. A generic URI is of the form:

scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]


从url返回PROTOCOL

hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'PROTOCOL');
OK
https


从url返回HOST

hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'HOST');
OK
www.baidu.com


从url返回PATH

hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'PATH');
OK
/s


从url返回QUERY

hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'QUERY');
OK
cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage


从url返回QUERY中指定的参数的值

从url返回QUERY中指定的参数的值
hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'QUERY', 'wd');
OK
大唐不夜城着火


从url返回FRAGMENT标识符

hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage#REGEXP_REPLACT', 'REF');
OK
REGEXP_REPLACT


从url返回FILE

//一般为 path?query
hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'FILE');
OK
/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage

hive> select parse_url('https://tester:[email protected]:8888/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'FILE');
OK
/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage

hive> select parse_url('https://tester:[email protected]:8888/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage#REGEXP_REPLACT', 'FILE');
OK
/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage


从url返回AUTHORITY

从url返回AUTHORITY
//userinfo@host:port
hive> select parse_url('https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'AUTHORITY');
OK
www.baidu.com

hive> select parse_url('https://www.baidu.com:8888/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'AUTHORITY');
OK
www.baidu.com:8888

hive> select parse_url('https://tester:[email protected]:8888/s?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'AUTHORITY');
OK
tester:[email protected]:8888


从url返回USERINFO

hive> select parse_url('http://tester:[email protected]?cl=3&tn=baidutop10&fr=top1000&wd=大唐不夜城着火&rsv_idx=2&rsv_dl=fyb_n_homepage', 'USERINFO');
OK
tester:123456

 

 

你可能感兴趣的:(hive)