How to detect which blog API

那年仲夏 提交于 2019-12-24 02:56:05

问题


Let's say that you want to create a dead simple BlogEditor and, one of your ideas, is to do what Live Writer does and ask only the URL of the persons Blog. How can you detect what type of blog is it?

Basic detection can be done with the URL itself, such as “http://myblog.blogger.com” etc. But what if it's self hosted?

I'm mostly interested on how to do this in Java, but this question could be also used as a reference for any other language.


回答1:


Many (most?) blogs will have a meta tag for "generator" which will list the blog engine. For example a blogger blog will contain the following meta tag:

<meta name="generator" content="Blogger" />  

My Subtext blog shows the following generator meta tag:

<meta name="Generator" content="Subtext Version 1.9.5.177" />  

This meta tag would be the first place to look. For blogs that don't set this meta tag in the source, you'd have to resort to looking for patterns to determine the blog type.




回答2:


Some blogs provide a Generator meta tag - e.g. Wordpress - you could find out if there's any exceptions to this.

You'll have to be careful how you detect it though, Google surprised me with this line:

<meta content='blogger' name='generator'/>

Single quotes are blasphemy.




回答3:


To determine other patterns to look for in determining the blogging engine (for those that don't have a generator meta tag), you'd basically just look through the source to determine something specific to that blog type. You'd also need to compare this across multiple blogs of that type as you want to make sure that it's not something specific to the skin or theme in use on the blog only.

Another thought would be to read the docs of the various common blogging engine to know how to discover the location of it's paths to things like MetaWebLog API, etc. IIRC, Live Writer has built-in support for the most common types, the rest are categorized "MetaWebLog API Blog" or something.



来源:https://stackoverflow.com/questions/26547/how-to-detect-which-blog-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!