Introduction to the structure of URLs

Source: Internet
Author: User
Tags server port

URL structure, about this aspect of the blog can also search a lot of ... Recently also looked at the basis, also recorded ...

Reference: Web-trapped

    1. What is a URL

The URL (Uniform Resource Locator) is a Uniform Resource locator that consists of a string of simple text characters. a specification-compliant The URL corresponds to a specific resource of the server (such as an HTML page, a picture, and so on).

Scheme:

//

Login:[email protected]

Address

:p ORT

/path/to/resource

? query_string

#fragment

According to the structure definition of the complete URL, divided into the above 8 parts, each part has certain characteristics, and some parts are necessary, and some are optional. The definition of the standard and the browser of the implementation of these standards are very different.

Scheme section: Protocol section.

The protocol name consists of a string of case-insensitive letters to : as a terminator. The Protocol represents the protocol that is used to obtain the resource. such as HTTP, HTTPS, and so on. The browser will support some additional protocols, such as data: and JavaScript: And so on.

Section: Hierarchy URL identification symbol

Basically, each URL contains this symbol, which is fixed, and can be understood as a symbol separating the protocol from the information that follows it. As the book explains, one benefit is that Web applications do not need to focus on the specific implementation of a protocol, but simply focus on the address that follows the '//' symbol.

But there are also URLs for this non-hierarchical structure: for example, mailto: protocol. When using

mailto:[email protected]?.... , the URL will be able to pass to the default mail client program without additional parsing.

Login:[email protected] section: Authentication

In fact, this piece of information we see relatively little, this is an optional part, the General protocol (HTTP\HTTPS, etc.) will use the default anonymous form of data acquisition, which uses @ as the end of the symbol.

Address section: Server addresses

This is a critical part, which is related to which server you need to get resources from. What we see is that this part is presented in the form of a domain name (htc.org), as well as the address of Ipv4 (220.181.111.188). Of course it can be presented in the form of Ipv6.

According to the standard description, this part can only be composed of: number, ".", "-". However, browsers will have more characters to support this .

Port section: Server port

This is the network port, 16-bit, so it can be selected as [0~2^16], where the port is not a physical port, but a logical port, as long as the data in order to handle multi-process transmission, the data will not be disturbed in the process, can be transmitted to the corresponding process set (reference:/HTTP Baike.baidu.com/link?url=mdemzljnepwavuuhgahpfzmnuk8z3ofgivz_qqpkor_hefxgdf6gf5pdjd7lvc_ XOAFGTA2D0AUGSIFRADL0KQ)

Different network protocols have their own specific port numbers: HTTP 80, for example

/path/to/resource: File path

The previously mentioned URL points to a uniquely determined resource, which points to the full path of the resource (that is, the location of the store), which is typically used/ for layering.

? query_string: Query string

The query string here is used for parameters passed to the server side. But the standard does not have a particularly strict rule on this part. This section starts as a logo, and now the general usage is similar to the following form, Name=hello&id=5&, ..., and this usage is also supported by server-side languages such as PHP, such as PHP to get the query value:

$_get [' ID '] $_post [' ID ']

#fragment: Fragment ID

The difference between this section and the form information that follows above is that this part will not be passed on to the server side. Usually used for the anchor of the page. It's our common site. The right foot usually has a button back to the top, which is generally achieved using it.

For example:

<!DOCTYPE HTML><HTML>    <Head>        <title>Return</title>        <Script>            functionfile () {varxx= "hello<br/>world<br/>" ;  for( varI= 0; I<  -; I++) {xx+= "<br/>" ; } xx+= "ni<br/>hao<br/>" ; document.getElementById ('AA'). InnerHTML=xx; }        </Script>    </Head>    <Bodyonload= "file ();">        <P>Nihao</P>        <BR>        <BR>        <aname= ' Hello '>Hello Hello Hello</a> <BR/>        <PID= ' AA '>        </P>        <ahref= "#hello">return Hello</a>        <ahref="#"Target= "_self">Back to Top</a>    </Body></HTML>

Python Gets the URL and handles

Reference:

Http://www.cnblogs.com/qq78292959/archive/2013/04/07/3005763.html

http://my.oschina.net/guol/blog/95699

Python gets this part of the information using the Urlparse module.

Parsing becomes 6 parts, returning tuples (scheme, Netloc, path, parameters, query, fragment)

Scheme:

//

Login:[email protected]

Address

:p ORT

/path/to/resource

? query_string

#fragment

 from Import  "Https://www.zhangsanlisi.com/questions/1000;hello_world?id=10&name=zhangsan#hello  "= urlparse (URL)print End_url

can correspond to the above, where Netloc describes the include authentication information + server address + port number, and the params is relatively small, basically more difficult to see, to specify specific parameters, reference (http://blog.csdn.net/yueguanghaidao/ article/details/16368399)

(semicolon) as the starting identity.

Structure of the URL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.