如何检测哪个博客API [英] How to detect which blog API

查看:24
本文介绍了如何检测哪个博客API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您想创建一个简单的博客编辑器,并且您的想法之一是执行 Live Writer 所做的工作,并且只询问人员博客的 URL.您如何检测它是什么类型的博客?

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?

基本检测可以通过 URL 本身完成,例如http://myblog.blogger.com"等.但是如果它是自托管的呢?

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

我最感兴趣的是如何在 Java 中做到这一点,但这个问题也可以用作任何其他语言的参考.

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.

推荐答案

许多(大多数?)博客都有一个元标记生成器",它将列出博客引擎.例如,博主博客将包含以下元标记:

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" />  

我的 Subtext 博客显示了以下生成器元标记:

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.

这篇关于如何检测哪个博客API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆