在浏览器中查看本地扩展名为.asp的html文件

发布于 2025-01-03 12:25:01 字数 159 浏览 1 评论 0原文

您好,我抓取了一个网站以供离线查看,但许多页面被下载并保存为 .asp,并且有指向这些页面的链接。但是当我在 Chrome 浏览器中打开这些扩展名为 .asp 的 html 页面时,chrome 会下载该页面而不是渲染该页面。有没有办法设置 chrome 来渲染页面而不是下载页面?

谢谢

Hi I have crawled a website for offline view, but many pages are downloaded and saved as .asp and there are links that point to these pages. But when I open these html page that has .asp extension in Chrome browser, the chrome will download the page instead of rendering the page. Is there a way to set the chrome to render the page instead of downloading it ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

冬天旳寂寞 2025-01-10 12:25:01

Chromium 对本地文件使用系统 mime 类型。在 Linux 上,您可以在 xdg-open 配置中更改它:

$ mkdir -p ~/.local/share/mime/packages
$ cd ~/.local/share/mime/packages
$ touch application-x-asp.xml

然后编辑~/.local/share/mime/packages/application-x-asp.xml

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="text/html">
        <comment>Active Server Page</comment>
        <icon name="text-html"/>
        <glob-deleteall/>
        <glob pattern="*.asp"/>
    </mime-type>
</mime-info>

将 mime-type 设置为 text/html。最后你必须再次注销/登录,或者只是运行:

$ update-desktop-database ~/.local/share/applications
$ update-mime-database    ~/.local/share/mime

Chromium uses the system mime-type for the local files. On Linux you can change it in the xdg-open configuration:

$ mkdir -p ~/.local/share/mime/packages
$ cd ~/.local/share/mime/packages
$ touch application-x-asp.xml

Then edit the ~/.local/share/mime/packages/application-x-asp.xml:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="text/html">
        <comment>Active Server Page</comment>
        <icon name="text-html"/>
        <glob-deleteall/>
        <glob pattern="*.asp"/>
    </mime-type>
</mime-info>

to set up the mime-type to text/html. On te end you have to logout/-in again, or just run:

$ update-desktop-database ~/.local/share/applications
$ update-mime-database    ~/.local/share/mime
同尘 2025-01-10 12:25:01

当您的浏览器打开文件时,它会使用 MIME 类型来决定应执行的操作,通常是下载或在浏览器中打开。

例如,它遇到一个 zip 文件,它会打开文件保存对话框并允许您保存该文件。

并且,例如,如果您从浏览器请求一个由 Web 服务器提供服务的 .asp,浏览器将使用 MIME 类型来决定采取哪个操作,哪些操作将显示在浏览器中。

MIME 类型将在 http 标头 中发送,这不会当您打开脱机 .asp 页面时发送到浏览器。

因此,如果您可以将 .asp 的 MIME 类型更改为“text/html”,它应该在浏览器中打开它。

不幸的是,Chrome 中似乎没有更改 MIME 类型/操作的选项。

您可以在 Firefox 中的“工具”>“工具”中更改这些设置选项>内容>>文件类型>管理..

在此处输入图像描述

When your browser opens a file it uses the MIME type to decide which action it should take, typically download or open in the bowser.

So, for example, it encounters a zip file it will open the file save dialogue box and allow you to save the file.

And, if for example, you request a .asp from your browser which is served from a web server the browser will use the MIME type to decide which action to take, which will be to display in the browser.

The MIME type will be sent within the http headers and this would not be sent to the browser when you open your off-line .asp pages.

So if you could change the MIME type to "text/html" for .asp it should open it in the browser.

Unfortunately, there does not seem to be an option for changing MIME type / actions in Chrome.

You can change these setting in Firefox within Tools > Options > Content > FileTypes > Manage..

enter image description here

属性 2025-01-10 12:25:01

有一种方法可以在 Firefox 中以 HTML 形式打开本地 .asp 文件。

找到您的 Firefox 配置文件文件夹。在 Windows 7 上,我在这里找到它:

C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\738xdie.default\mimeTypes.rdf

然后将这些行添加到 mimeTypes.rdf

<RDF:Description RDF:about="urn:mimetype:text/html"
    NC:fileExtensions="asp"
    NC:description="ASP Pages"
    NC:value="text/html"
    NC:editable="true">
</RDF:Description>

重新启动浏览器。您的本地文件现在将呈现为 HTML。

Chrome 可能也有类似的技术。

There is a way to open local, .asp files as HTML in Firefox.

Find your Firefox profile folder. On Windows 7, I found it here:

C:\Users\user\AppData\Roaming\Mozilla\Firefox\Profiles\738xdie.default\mimeTypes.rdf

Then add these lines to mimeTypes.rdf

<RDF:Description RDF:about="urn:mimetype:text/html"
    NC:fileExtensions="asp"
    NC:description="ASP Pages"
    NC:value="text/html"
    NC:editable="true">
</RDF:Description>

Restart browser. Your local file will now render as HTML.

There may be a similar technique with Chrome.

清风疏影 2025-01-10 12:25:01

我想您想直接查看下载的页面,而不是通过某些本地网络服务器。然后我建议在下载过程中根据响应标头报告的内容类型更改(或附加)文件扩展名。当然,这将需要调整其他文件中已更改文件名的所有链接。另一种方法可能是将每个页面的内容类型存储在元数据库中,并使用本地 Web 服务器根据数据库中的实际类型(而不是文件扩展名)来提供文件。

I suppose you want to view downloaded pages directly, that is not via some local web-server. Then I'd suggest to change (or append) file extensions during download according to their reported content-types from response headers. Of course, this will require to adjust all links to changed filenames inside other files. The other approach could be to store content-type of each page in a meta-base, and using a local web-server to serve the files according to their actual types from the base, not file extensions.

想你的星星会说话 2025-01-10 12:25:01

我有两个解决方案给你。第一个是用火狐打开这些文件..就是这样..
如果你坚持用chrome打开它们。您必须将所有文件扩展名更改为 html 而不是 asp。使用一些程序来重命名..
但页面之间的链接将被破坏..
所以你必须找到所有页面使用的js文件,在其中添加此代码来修复链接

document.body.addEventListener('click',function(e){
if(e.target.nodeName=='A'){
e.preventDefault()
href=e.target.href.split('/')
href[href.length-1]=href[href.length-1].replace('.asp','.html')
href=href.join('/')
parent.location=href
}
})

})

I have two solutions for you. the first one is to open those files with firefox.. and that's it..
if you insist to open them with chrome. you have to change all files extension to html instead of asp. use some programs for renaming..
but the links will be broken between pages..
so you have to find the js file that all pages use add this code in it to fix the links

document.body.addEventListener('click',function(e){
if(e.target.nodeName=='A'){
e.preventDefault()
href=e.target.href.split('/')
href[href.length-1]=href[href.length-1].replace('.asp','.html')
href=href.join('/')
parent.location=href
}
})

})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文