【问题标题】:How to upload multiple blog posts in BlogSpot at once?如何一次在 BlogSpot 中上传多篇博客文章?
【发布时间】:2021-09-26 08:44:28
【问题描述】:

我总共写了 86 篇博文。我尝试手动上传它,但似乎是一个漫长的过程,所以我决定通过 xml 文件制作并处理它,但网络上没有 xml 格式对我有帮助。这是我尝试过的代码,

<?xml version='1.0' encoding='UTF-8'?> 
<ns0:feed xmlns:ns0="http://www.w3.org/2005/Atom"> 
<ns0:generator>Blogger</ns0:generator>
<ns0:entry> 
<ns0:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/blogger/2008/kind#post" /> 
<ns0:category scheme="http://www.blogger.com/atom/ns#" term="CATEGORY A" />
<ns0:id>BLOGGER TEST</ns0:id> 
<ns0:content type="html">Blogger CONTENT</ns0:content> 
<ns0:title type="html">BLOGGER TITLE</ns0:title> 
</ns0:entry> 
</ns0:feed>

如果使用 xml 是不好的选择,那么在 python 或任何其他编码中的任何机会。

【问题讨论】:

  • 分享blogger API,让您上传基于xml的博客。

标签: python xml blogger blogs


【解决方案1】:

使用 API,如下例所示

POST https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/
Authorization: /* OAuth 2.0 token here */
Content-Type: application/json

{
  "kind": "blogger#post",
  "blog": {
    "id": "8070105920543249955"
  },
  "title": "A new post",
  "content": "With <b>exciting</b> content..."
}

更多信息请看这里: https://developers.google.com/blogger/docs/3.0/using#AddingAPost

【讨论】:

    【解决方案2】:

    您可以通过将 POST 请求发送到带有帖子 JSON 正文的收集后 URI 来为博客添加帖子:

    https://www.googleapis.com/blogger/v3/blogs/YOUR_BLOG_ID/posts/
    

    请求(您必须经过身份验证才能创建帖子):

    POST https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/
    Authorization: /* OAuth 2.0 token here */
    Content-Type: application/json
    
    {
      "kind": "blogger#post",
      "blog": {
        "id": "8070105920543249955"
      },
      "title": "A new post",
      "content": "With <b>exciting</b> content..."
    }
    

    响应(如果您的请求成功,您将获得 HTTP 200 OK 状态):

    {
     "kind": "blogger#post",
     "id": "6819100329896798058",
     "blog": {
      "id": "8070105920543249955"
     },
     "published": "2012-05-20T20:08:00-07:00",
     "updated": "2012-05-20T20:08:35-07:00",
     "url": "http://brettmorgan-test2.blogspot.com/2012/05/new-post.html",
     "selfLink": "https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/6819100329896798058",
     "title": "A new post",
     "content": "With <b>exciting</b> content...",
     "author": {
      "id": "16258312240222542576",
      "displayName": "Brett Morgan",
      "url": "http://www.blogger.com/profile/16258312240222542576",
      "image": {
       "url": "https://resources.blogblog.com/img/b16-rounded.gif"
      }
     },
     "replies": {
      "totalItems": "0",
      "selfLink": "https://www.googleapis.com/blogger/v3/blogs/8070105920543249955/posts/6819100329896798058/comments"
     }
    }
    

    有关更多详细信息,请阅读 API 文档。 https://developers.google.com/blogger/docs/3.0/using

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-17
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 2015-06-26
      • 1970-01-01
      • 1970-01-01
      • 2015-12-01
      相关资源
      最近更新 更多