一不小心把 Instapaper 删了,再去 App Store 下,告我在中国区下架了😱 MD,自己写一个去!
首先,打开 Instapaper 的书签🔖看看它是怎么工作的:
javascript:function iprl5()%7Bvar d%3Ddocument,z%3Dd.createElement(%27scr%27%2B%27ipt%27),b%3Dd.body,l%3Dd.location%3Btry%7Bif(!b)throw(0)%3Bd.title%3D%27(Saving...) %27%2Bd.title%3Bz.setAttribute(%27src%27,l.protocol%2B%27//www.instapaper.com/j/8Scj0SgReZEA%3Fa%3Dread-later%26u%3D%27%2BencodeURIComponent(l.href)%2B%27%26t%3D%27%2B(new Date().getTime()))%3Bb.appendChild(z)%3B%7Dcatch(e)%7Balert(%27Please wait until the page has loaded.%27)%3B%7D%7Diprl5()%3Bvoid(0)
用CGI.unescape()
转码一下,发现原来是跟服务器发了条消息,告诉它文章的链接(存在u
里面) & 当下的时间(存在t
里面,以毫秒记):
javascript: function iprl5() {
var d = document,
z = d.createElement('scr' + 'ipt'),
b = d.body,
l = d.location;
try {
if (!b) throw (0);
d.title = '(Saving...) ' + d.title;
z.setAttribute('src', l.protocol + '//www.instapaper.com/j/xxxxxxxxxxxx?a=read-later&u=' + encodeURIComponent(l.href) + '&t=' + (new Date().getTime()));
b.appendChild(z);
} catch (e) {
alert('Please wait until the page has loaded.');
}
}
iprl5();
void(0)
note:
xxxxxxxxxxxx
是某种口令。
接下来就牛逼了。Instapaper 直接返回了一~大~段 JavaScript 脚本,把网页抓回去了😱 之前,我一直以为是后台抓的😱
框架大概是这样的:
-
document.body.appendChild(_overlayipbxxxxxx());
:xxxxxx
是一串全文同一的数字。 -
overlayipbxxxxxx()
生成一个id
为ovipbxxxxxx
的div
块,设置一些属性。然后依次调用: o.appendChild(_logoipbxxxxxx())
o.appendChild(_cancelButtonipbxxxxxx())
o.appendChild(_folderDropdownipbxxxxxx())
o.appendChild(_statusTitleipbxxxxxx())
对了,中间 Instapaper 会传来一段 json 数据:
{ "folders" : [ ], "bookmark_id" : xxxxxxxxx }
MD,好复杂,算了,反正可以拿到链接了,让后台抓去吧。主要是没解决 Sinatra 怎么回传的问题😓