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?
假设您想创建一个简单的BlogEditor,而您的一个想法就是做Live Writer所做的事情,只询问人物Blog的URL。你怎么能发现它是什么类型的博客?
Basic detection can be done with the URL itself, such as “http://myblog.blogger.com” etc. But what if it's self hosted?
可以使用URL本身进行基本检测,例如“http://myblog.blogger.com”等。但是如果它是自托管的呢?
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.
我最感兴趣的是如何在Java中执行此操作,但此问题也可以用作任何其他语言的参考。
3 个解决方案
#1
3
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:
我的Subtext博客显示以下生成器元标记:
<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
1
Some blogs provide a Generator meta tag - e.g. Wordpress - you could find out if there's any exceptions to this.
一些博客提供了一个Generator元标记 - 例如Wordpress - 您可以查看是否有任何例外。
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
1
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.
另一个想法是阅读各种常见博客引擎的文档,以了解如何发现它的路径,如MetaWebLog API等.IIRC,Live Writer内置支持最常见的类型,其余的是分类“MetaWebLog API博客”或其他东西。
#1
3
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:
我的Subtext博客显示以下生成器元标记:
<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
1
Some blogs provide a Generator meta tag - e.g. Wordpress - you could find out if there's any exceptions to this.
一些博客提供了一个Generator元标记 - 例如Wordpress - 您可以查看是否有任何例外。
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
1
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.
另一个想法是阅读各种常见博客引擎的文档,以了解如何发现它的路径,如MetaWebLog API等.IIRC,Live Writer内置支持最常见的类型,其余的是分类“MetaWebLog API博客”或其他东西。