URL通用格式 我编写了一个C++程序,允许URL发布到YouTube上。它的工作原理是将URL作为输入输入,输入程序或直接输入,然后将字符串中的每个“/”、“.”替换为“*”。然后将修改后的字符串放在剪贴板上(仅限Windows用户使用)

URL通用格式 我编写了一个C++程序,允许URL发布到YouTube上。它的工作原理是将URL作为输入输入,输入程序或直接输入,然后将字符串中的每个“/”、“.”替换为“*”。然后将修改后的字符串放在剪贴板上(仅限Windows用户使用),c++,url,format,C++,Url,Format,当然,在调用该程序之前,它必须返回:我需要知道URL中何时使用“.”、“/”。我看过这篇文章:,知道在处理“主网站”(在这个URL中是“en.wikipedia.org”)时使用“/”,然后使用“/”,但我去过其他网站,但事实并非如此(它甚至分别用“%28”、“29”替换了“(”、“)”) 我似乎还请求了一个.aspx文件,不管是什么。此外,该URL的括号内还有一个“.”。我甚至尝试查看关于URL的正则表达式(我还不完全理解这些…)。有人能告诉我(或给我链接)关于在URL中使用“.”、“/”的规

当然,在调用该程序之前,它必须返回:我需要知道URL中何时使用“.”、“/”。我看过这篇文章:,知道在处理“主网站”(在这个URL中是“en.wikipedia.org”)时使用“/”,然后使用“/”,但我去过其他网站,但事实并非如此(它甚至分别用“%28”、“29”替换了“(”、“)”)


我似乎还请求了一个.aspx文件,不管是什么。此外,该URL的括号内还有一个“.”。我甚至尝试查看关于URL的正则表达式(我还不完全理解这些…)。有人能告诉我(或给我链接)关于在URL中使用“.”、“/”的规则吗?

你能解释一下你为什么要这么做吗?你想达到什么目标?一旦你回答了这个问题,你可能不需要知道你想的那么多

同时,这里有一些信息。URL实际上由许多部分组成

http:     - the "scheme" or protocol used to access the resource. "HTTP", "HTTPS",
            "FTP", etc are all examples of a scheme. There are many others

//        - separates the protocol from the host (server) address

myserver.org - the host. The host name is looked up against a DNS (Dynamic Name Server)
            service and resolved to an IP address - the "phone number" of the machine
            which can serve up the resource (like "98.139.183.24" for www.yahoo.com)

www.myserver.org - the host with a prefix. Sometimes the same domain (`myserver.org`)
            connects multiple servers (or ports) and you can be sent straight to the
            right server with the prefix (mail., www., ftp., ... up to the
            administrators of the domain). Conventionally, a server that serves content
            intended for viewing with a browser has a `www.` prefix, but there's no rule
            that says this must be the case. 

:8080/    - sometimes, you see a colon followed by up to five digits after the domain.
            this indicates the PORT on the server where you are accessing data
            some servers allow certain specific services on just a particular port
            they might have a "public access" website on port 80, and another one on 8080
            the https:// protocol defaults to port 443, there are ports for telnet, ftp, 
            etc. Add these things only if you REALLY know what you are doing.

/the/pa.th/ this is the path relative to DOCUMENTROOT on the server where the
            resource is located. `.` characters are legal here, just as they are in
            directory structures. 

file.html
file.php
file.asp
etc       - usually the resource being fetched is a file. The file may have
            any of a great number of extensions; some of these indicate to the server that
            instead of sending the file straight to the requester,
            it has to execute a program or other instructions in this file,
            and send the result of that
            Examples of extensions that indicate "active" pages include
            (this is not nearly exhaustive - just "for instance"):
            .php = contains a php program
            .py  = contains a python program
            .js  = contains a javascript program
                   (usually called from inside an .htm or .html)
            .asp = "active server page" associated with a
                   Microsoft Internet Information Server
?something=value&somethingElse=%23其他值%23 传递给服务器的参数可以显示在URL中。 这可用于传递参数、表单中的条目等。 可以在此处传递任何字符-包括“.”、“&”、“/”、。。。 但是你不能只在字符串中写这些字符

现在是有趣的部分

URL不能包含某些字符(实际上是相当多的字符)。为了避免这种情况,存在一种称为“转义”角色的机制。通常这意味着将字符替换为十六进制等效字符,前缀为
%
符号。因此,例如,您经常会看到一个表示为%20的空格字符。你可以找到一份简单的清单

有许多函数可用于将URL中的“非法”字符自动转换为“合法”值

要准确了解什么是允许的,什么是不允许的,您确实需要回到原始规范。例如,见

我按时间顺序列出它们——最后一个是最近的


但我重复我的问题——你到底想做什么,为什么?

在你链接的维基百科文章底部的“参考”下,是相关规范的进一步链接。这里没有快速有效的答案;你需要花一些时间阅读它们,然后才能继续。我正在努力做到这一点,这样你就可以在YouTube(或一些不允许网站的论坛)上发布链接。我这样做是因为有时人们浏览某个页面可能会因为知道其他人在浏览该页面时发现了什么而受益。例如,我在YouTube上看了一段关于一个名叫劳埃德·欧文(Lloyd Irvin)(可能是邪恶的)男人的视频。他被指控在他的武术学校链中经营一个“邪教”,我有一些关于那个“人”的信息。我无法发布它,因为YouTube的URL-ban非常严格。天哪,我现在知道URL解密器/加密器有多复杂了!简单的部分是“加密”一个有效的URL…困难的部分将是检查,不仅是链接是否有效,而且它是否符合您发送给我的所有内容,更不用说与谷歌搜索相对应的URL看起来与其他网站大不相同(就“.”,“/”而言)//听起来像是一个试错过程谷歌是你的朋友。在你的目标网站上找到一个看起来相当独特的短语(“短语”可以跨越多个句子),将其复制到你的搜索框中,用引号括起来,并确认你只点击了一次——你想要链接的页面。告诉人们“谷歌”这个网站上的独特短语“——你刚刚创建了一个“编码的独特资源定位器”。编写一些自动执行此操作的代码(找到一个独特的短语,用谷歌搜索它,确认有一个命中率)会很有趣。例如:如果你看上面的问题,我会觉得“在你的剪贴板上(这是唯一的)”是一个非常不可能的字符串。当然,当你在谷歌中键入“在你的剪贴板上,这是唯一的”(加上“精确匹配”的双引号),你只会得到一次点击——这一页。