开发者

cURL - Fetch data only if html page (link)

I am building a CSS Optimizer website, in this I will offer a option where a user submits a Website URL and on backend, server will parse all the anchors and link tags wi开发者_如何学Pythonthin that domain. So this will enable the site to concatenate + compress the css which may be unique on all different pages.

As all my website needs is anchor (html) and <link> what should I do to avoid fetching links that are non-html (like .doc, .pdf) etc


I don't think you can reply on just the extensions of targets. Clean URLs don't often have extensions at the end, content might be generated.

You should probably do an HTTP HEAD on every URL and then check the Content-Type which is returned.


What about checking the mime type of the related link with mime_content_type()?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜