gpt4 book ai didi

python - 在 python 中调用片段标识符 '#' 的任何方法

转载 作者:太空宇宙 更新时间:2023-11-04 11:02:30 25 4
gpt4 key购买 nike

有什么方法可以从 python 调用片段标识符吗?我目前正在使用 python mechanize。

最佳答案

我觉得这个earlier question保留你的答案:

In the HTTP protocol, the fragment (from # onwards) is not sent to the server across the network: it's locally retained by the browser and used, once the server's response is fully received, to somehow "visually locate" the exact spot in the page to be shown as "current" (for example, if the returned page is in HTML, this will be done by parsing the HTML and looking for the first suitable flag).

Alex Martelli 的行动建议也成立:

So, the procedure is: remove the fragment e.g. via urlparse.urlparse; use the rest to fetch the resource; parse it appropriately based on the server response's content-type header; then take whatever visual action your program does regarding the "current spot" on the resource, based on locating within the parsed resource the fragment you retained in the first step.

关于python - 在 python 中调用片段标识符 '#' 的任何方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4060110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com