admin管理员组文章数量:1400174
Is there a way to request only the head portion of an HTML page without needing to download the plete webpage? I am only interested meta tags like description, keywords and title (tag).
To generalize are there any HTTP methods that I could use to only request specific tags from a server without needing to download the whole webpage ?
Please let me know.
Is there a way to request only the head portion of an HTML page without needing to download the plete webpage? I am only interested meta tags like description, keywords and title (tag).
To generalize are there any HTTP methods that I could use to only request specific tags from a server without needing to download the whole webpage ?
Please let me know.
Share Improve this question asked Oct 25, 2015 at 13:55 trktrk 2,22815 silver badges21 bronze badges 4-
Make yourself familiar with the '
HEAD
' Method of the http protocol. – Axel Amthor Commented Oct 25, 2015 at 14:04 -
1
@Axel requesting an HTML page with the
HEAD
method is not going to yield any HTML. – CodeCaster Commented Oct 25, 2015 at 14:05 - 1 @CodeCaster oops yes, you're right. doesn't answer this question. – Axel Amthor Commented Oct 25, 2015 at 14:12
- You may use streaming HTML parser and close the stream (drop connection) once you got the desired data. – Juicy Scripter Commented Oct 25, 2015 at 14:41
2 Answers
Reset to default 6The things you're looking for are defined at the HTML level, a couple of layers above the HTTP layer. So no, there's no foolproof way to only request certain tags from an HTML page.
Given those tags are bound to be present in the <head>
section of the page, you can stop reading the response after you encountered the </head>
tag though - if the HTML is well-formed.
No.
The closest HTTP has is the Range header which lets you request specific bytes from servers which support it.
The problem is that you can't reliably know how many bytes the head section of the document will take up before you request it.
本文标签: javascriptRequest only meta tags from a webpageStack Overflow
版权声明:本文标题:javascript - Request only meta tags from a webpage - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744184721a2594236.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论