Python:运行 wget 命令导致它忽略 URL 中散列后的任何内容

Python: Running wget command results in it ignoring anything atter the hash in URL

我在这里为 wget 调用命令 url http://pypi.org/project/pip/#files

    self.run_command('("wget http://pypi.org/project/pip/\#files -O index1.html")')

我的日志认为我 运行 它从哈希开始没有任何东西

2020-01-27 11:37:23,128 020776:084 INFO:  wget http://pypi.org/project/pip/

我试过不使用引号、括号和转义字符,但得到的结果相同。有人知道吗?

散列被解释为 CLI 上的注释字符,因此,它后面的所有内容都将被忽略。

在 URL 中,散列表示浏览器应滚动到的锚点。在 RFC3986 的 URL 定义中写道,哈希部分(称为片段)永远不会传输到服务器。即,您可以将其从 URL 中删除并使用:

self.run_command('("wget http://pypi.org/project/pip/ -O index1.html")')

除此之外: 1. 为什么不直接使用 python 的 HTTP 接口(而不是生成进程)? 2.为什么不直接使用画中画API?