1. Hive's Parse_url functionParse_url (URL, parttoextract[, key])-extracts a part from a URL parsing url string, parttoextract option contains [Host,path,query,ref, Protocol,file,authority,userinfo]. Examples of "Host,path,query,ref,protocol,file,authority,userinfo":Select Parse_url (' Http://facebook.com/path/p1.php?query=1 ', ' PROTOCOL') from dual; --http
SelectParse_url (' Http://facebook.com/path/p1.php?query=1 ', 'HOST ') from dual;---facebook.com?
SelectParse_url (' Http://facebook.com/path/p1.php?query=1 ', ' REF ') from dual;---empty?
SelectParse_url (' Http://facebook.com/path/p1.php?query=1 ', 'PATH ') from dual;---/path/p1.php?
SelectParse_url (' Http://facebook.com/path/p1.php?query=1 ', 'QUERY ') from dual;---empty?
?SelectParse_url (' Http://facebook.com/path/p1.php?query=1 ', ' FILE ') from dual;? ---/path/p1.php?query=1?
? Select parse_url (' Http://facebook.com/path/p1.php?query=1 ', ' authority ') from dual;? ---facebook.com?
? Select parse_url (' Http://facebook.com/path/p1.php?query=1 ', ' USERINFO ') from dual;? ---empty The following can be seen without looking at ===========================================================
2. URL explanationThe URL (Uniform resoure Locator Uniform Resource Locator) is the address of the WWW Web page, like a street address on a city map. URLs use numbers and letters arranged in a certain order to determine an address. The first part of a URL
http ://Indicates the
type of file to be accessed . On the Internet, this almost always uses HTTP (meaning Hypertext Conversion Protocol, Hypertexttransfer protocol.) because it is the protocol used to convert web pages.) Sometimes also use FTP (filetransferprotocol), meaning for the file Transfer Protocol, mainly used to transfer software and large files (many do software download Web site using ftp as the download URL); telenet (telnet), mainly for remote chat, and file calls, etc., It means that the browser is reading a file outside the site, not a remote computer.URLs from left to right are made up of the following sections:
(1) Internet resource type (scheme): The tool that the WWW client program uses for C. For example, "http://" means the WWW server, "ftp://" means the FTP server, "gopher://" represents the gopher server, and "new" represents the NewGroup newsgroup. • Server address (host): Indicates the server domain name where the WWW web page resides.
(2) ports (port): sometimes (not always), access to certain resources requires a port number for the appropriate server.
(3) path: Indicates the location of a resource on the server (in the same format as the DOS system, usually with a directory/subdirectory/file name). As with ports, paths are not always required. The URL address format is: Scheme://host:port/path For example, Http://www.maogoo.com/bbs is a typical URL address. The client program first sees the HTTP (Hypertext Transfer Protocol) and knows that the HTML link is being processed. The next www.maogoo.com is the site address, and finally the directory/bbs must be aware that the WWW servers are case-sensitive letters, so be sure to pay attention to the correct URL case representation.
3. URL parsingURL: Uniform Resource Locator (Uniform Resource locator,url) Full URL consists of these parts:scheme://host:port/path?query#fragment Scheme: Common Http,ftp,maito for communication protocols such as host: Host server (computer) domain Name System (DNS) hostname or IP address. port: The port number integer, optional, is omitted when the default port for the scenario is used, such as HTTP with the default port of 80. path: A string separated by 0 or more "/" symbols, typically used to represent a directory or file address on a host. query: Queries are optional for use with dynamic Web pages such as CGI, ISAPI, php/jsp/asp/asp. NET and other technical Web pages) pass parameters, can have multiple parameters, separated by the "&" symbol, the name and value of each parameter is separated by the "=" symbol. fragment: A message fragment string that specifies a fragment in a network resource. For example, there are multiple noun interpretations in a Web page, and you can use fragment to navigate directly to a noun interpretation. (also known as anchor points.) for such a url http://www.x2y2.com:80/fisker/post/0703/window.location.html?ver=1.0&id=6#imhere we can use JavaScript to get the various parts of 1, window.location.href the entire URL string (the full address bar in the browser) This example returns the value: http://www.x2y2.com:80/ The Fisker/post/0703/window.location.html?ver=1.0&id=6#imhere 2,window.location.protocolurl Protocol section of this example returns a value: Http: 3,window.location.hosturl the host part of this example returns a value: The port portion of the Www.x2y2.com 4,window.location.portURL if the default port of 80 is used ( Update: Even if: 80 is added, the return value is not the default of 80 but the null character into returns the value: "" The path portion of the 5,window.location.pathnameurl (that is, the file address) The return value of this example:/FIsker/post/0703/window.location.html 6,window.location.search Query (Parameters) section in addition to the dynamic language assignment, we can also give static pages, and use JavaScript to get the value of the parameter that you believe should be the return value of this example:? Ver=1.0&id=6 7,window.location.hash Anchor Point This example returns the value: #imhere
Use of Parse_url in Hive