coldfusion - 使用 Coldfusion 仅获取远程 URL 的 HTTP header

标签 coldfusion http-headers web-crawler cfhttp

我有一个函数可以解析给它的网址,并根据在该页面上找到的内容决定使用开放图来显示嵌入视频,仅显示标题等。

我想扩展它来检测是否已将直接视频文件或音乐文件作为 URL 提供。

我根本没有兴趣下载文件的全部内容,但我确实只想先查看标题,看看它是否是音频/mpg、文本、html 等。

有没有办法获取远程文件/页面的http header 而不获取所有内容?

使用 CFHTTP,它将连接并为我提供所需的数据,但它占用了下载其余内容的处理时间。

通过了解 header 内容,我可以决定是否应该尝试下载整个页面以解析它以获取额外的开放图形数据。

最佳答案

尝试<cfhttp>method="head"

HEAD: identical to the GET method, but the server does not send a message body in the response. Use this method for testing hypertext links for validity and accessibility, determining the type or modification time of a document, or determining the type of server.

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ffc.html

关于coldfusion - 使用 Coldfusion 仅获取远程 URL 的 HTTP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312406/

相关文章:

php - 如何在登录后重定向一个人

php - 我可以关闭 PHPSESSID 吗?为什么它会出现在我的 cookie 上?

AJAX 用问号而不是 hashbang 抓取

list - 我应该如何在 CFQUERYPARAM 列表 ="true"中使用 maxlength ?

coldfusion - 使用 getPageContext().getRequest().getParameterValues() 时如何防止 unicode 字符损坏?

coldfusion - 如何在某些 java 类或包上限制 createObject()?

python-3.x - python中通过爬取子URL来下载文件

coldfusion - 迁移到负载平衡环境是否需要更改代码级别?

c# - 必须使用适当的属性或方法来修改 'Accept' header 。参数名称: name

python - 我如何使用 scrapy 为 crawlspider 创建规则