LoginSignup
0
0

Evernote の共有リンクから note の内容を取得

Posted at

Evernote の共有リンクから、内容を機械的に取得する方法

何のために?

進捗ボットを使ってメンバーの成果物が進んでいるかどうかチェックする。Evernote で書かれた成果物があるのでそれもチェックする。
Evernote には、共有したノートの更新を第三者に自動通知する方法とかが無い?
なのでポーリングして調べる。

先に結論

共有リンクの後ろに ?json=1&rdata=0 を付けてアクセスする。

以下はコレを調べた方法です。

共有リンクを作るやりかたを復習

以下のようなノートを作ります。
image.png

共有リンクを作る

image.png

これから作ったのは以下のリンク。

https://www.evernote.com/shard/s738/sh/a026e155-b0b7-c840-799a-f9ad0993e1d6/uJ1ZvZT8afR4nFugZ8VPo3UKuUyleeji_VaKH1S956YTZF03GEGrnVrIzA

第三者がこのリンクを開くと以下のように完全に表示される。
image.png

wget で内容が取得できない件

しかしながらこのリンクを wget で取得すると・・・
image.png

ここからコンテンツ部分を抜き出すと、
<meta property="og:type" content="article"/><meta property="og:description" content="(20240625 &#26178;&#28857;) Create NIP-16 Contact MJ-12 OMCUSS maintenance OMCUSS schedule 202406 add files to repository Raspberry Pi files Create repository Raspberry Pi KiCad files STM32 KiCad files remote&nbsp;site ..."/>

となっていて、なんとなく読めそうなのだけれど途中までしか入っていない。

これを全部読むためにはどうしたらいいかな?

資料調査

https://dev.evernote.com/doc/articles/note_links.php
によると、

Public Links

Public Links are used to share a note with users who do not already have access to the note and is intended to open in a browser.

Structure:

 https://[service]/shard/[shard ID]/sh/[noteGuid]/[shareKey]/

Where:

[service] is the name of the Evernote service (www.evernote.com)
[shardId] is the shard ID where the note is stored
[noteGuid] is the GUID of the note that is being linked to
[shareKey] is the share key of the note. The shareKey is generated by calling the shareNote method on

となっている。

先のリンク

https://www.evernote.com/shard/s738/sh/a026e155-b0b7-c840-799a-f9ad0993e1d6/uJ1ZvZT8afR4nFugZ8VPo3UKuUyleeji_VaKH1S956YTZF03GEGrnVrIzA

だと、以下のようになるみたいですね。

service shardId noteGuid shareKey
www.evernote.com s738 a026e155-b0b7-c840-799a-f9ad0993e1d6 uJ1ZvZT8afR4nFugZ8VPo3UKuUyleeji_VaKH1S956YTZF03GEGrnVrIzA

これ以上詳しい資料は無いみたい。

Hack

Chrome の Developer ツールで調べる。
image.png

これの responce を見てみると、全部含まれている。

{
    "guid": "a026e155-b0b7-c840-799a-f9ad0993e1d6",
    "title": "ToDo リスト",
    "content": "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note><ol><li><div>(20240625 時点) </div></li><li><div>Create NIP-16</div></li><li><div>Contact MJ-12</div></li><li><div>OMCUSS maintenance</div></li></ol><div><br/></div><div><span style=\"font-size: 36px;\">OMCUSS schedule</span></div><ul><li><div>202406</div></li><ul><li><div>add files to repository </div></li><ul><li><div>Raspberry Pi files</div></li></ul><li><div>Create repository</div></li><ul><li><div>Raspberry Pi KiCad files</div></li><li><div>STM32 KiCad files</div></li></ul><li><div>remote  site maintenance</div></li></ul><li><div>202407</div></li><ul><li><div> on site maintenance</div></li></ul></ul><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></en-note>",
    "created": 1719293655000,
    "updated": 1719294599000,
    "attributes": {
        "author": "nanbuwks_evernote",
        "shareDate": 1719293853000
    }
}

これのリクエスト情報は
image.png

/shard/s738/sh/a026e155-b0b7-c840-799a-f9ad0993e1d6/uJ1ZvZT8afR4nFugZ8VPo3UKuUyleeji_VaKH1S956YTZF03GEGrnVrIzA?json=1&rdata=0
ということで、先の共有リンク

https://www.evernote.com/shard/s738/sh/a026e155-b0b7-c840-799a-f9ad0993e1d6/uJ1ZvZT8afR4nFugZ8VPo3UKuUyleeji_VaKH1S956YTZF03GEGrnVrIzA

に手を加えて以下のようにする。

https://www.evernote.com/shard/s738/sh/a026e155-b0b7-c840-799a-f9ad0993e1d6/uJ1ZvZT8afR4nFugZ8VPo3UKuUyleeji_VaKH1S956YTZF03GEGrnVrIzA?json=1&rdata=0

これを wget で読ませると

{"guid":"a026e155-b0b7-c840-799a-f9ad0993e1d6","title":"ToDo リスト","content":"<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"><en-note><ol><li><div>(20240625 時点) </div></li><li><div>Create NIP-16</div></li><li><div>Contact MJ-12</div></li><li><div>OMCUSS maintenance</div></li></ol><div><br/></div><div><span style=\"font-size: 36px;\">OMCUSS schedule</span></div><ul><li><div>202406</div></li><ul><li><div>add files to repository </div></li><ul><li><div>Raspberry Pi files</div></li></ul><li><div>Create repository</div></li><ul><li><div>Raspberry Pi KiCad files</div></li><li><div>STM32 KiCad files</div></li></ul><li><div>remote  site maintenance</div></li></ul><li><div>202407</div></li><ul><li><div> on site maintenance</div></li></ul></ul><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></en-note>","created":1719293655000,"updated":1719294599000,"attributes":{"author":"nanbuwks_evernote","shareDate":1719293853000}}

となり、先の responce と同じ内容が取得できました。

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