0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

はてなブログ {entry_id}を取得してみた

0
Last updated at Posted at 2023-07-14

はてなブログAtomPubのAPIにて、entry_idを取得するサンプルです。色々やり方はあると思いますが、GASを利用して下記画像(HTTPレスポンス)の選択しているところを正規表現で引っこ抜くだけのシンプルなプログラムです。

スクリーンショット 2023-07-14 22.27.10.png

GAS
//ブログエントリ結果を取得(諸々省略して結果取得のみ)
var ret = UrlFetchApp.fetch(url,options);

//レスポンスから正規表現でentry_idを抽出
var m = ret.getContentText().match(/atom\/entry\/([0-9]+)/g)
var entry_id = m[0].replace("atom/entry/","")

console.log(entry_id)

投稿元データと合わせてentry_idを保存しておくと、更新や削除に利用できるので便利です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?