Movatterモバイル変換


[0]ホーム

URL:


はてラボはてな匿名ダイアリー
ようこそ ゲスト さんログインユーザー登録
< http://anond.hatelabo.jp/20130... |正社員の面接に行きま... >

2013-06-30

AutoPagerizeを連番URLでも使えるようにする

page-1 page-2 page-3みたいなやつ

autopagerize incrementalでググるとそれっぽいのが出てくる

こんなかんじの記述Autopagerize適当場所に追加したら連番URLでも使えるようになるはず

varpages = getElementsByXPath(this.info.pageElement, htmlDoc);

varurl = this.getNextURL(this.info.nextLink, htmlDoc);

if (this.info.incremental) {

var exp = newRegExp(this.info.incremental.nextMatch,'i');

var _m = this.info.incremental.nextLink;

var step = this.info.incremental.step || 1;

url = this.requestURL.replace(exp,function(m0,m1){

var n = parseInt(m1,10) + step;

return _m.split('#').join(n);

});

}

varnext = getFirstElementByXPath(xpath,doc);

if (next) {

if (this.info.incremental) {

varloc = this.requestURL ||location.href;

var exp = newRegExp(this.info.incremental.nextMatch,'i');

varnextLink = this.info.incremental.nextLink;

var step = this.info.incremental.step || 1;

if (loc.match(exp)) {

returnloc.replace(exp,nextLink.replace("#",parseInt(RegExp.$1)+step));

} else if (!loc.match(exp)) {

returnloc +nextLink.replace("#",step);

}

} else {

returnnext.getAttribute('href') ||next.getAttribute('action') ||next.getAttribute('value');

}

}

連番に適応するSITEINFOはこんなかんじになる

pageelementは普通のsiteinfoと同じ

nextlinkはリンクをたどるわけじゃないので意味ないのだが一応書いておく必要があるので'//a'とでも書いておけばいい

url: '^http://matome\.naver\.jp/odai/'

,incremental: {

nextMatch: 'page=(\\d+)'

,nextLink: 'page=#'

}

,pageElement: '//div[@role="main"]'

,nextLink: '//a'

サンプル

http://matome.naver.jp/odai/2135645268395674701

Permalink |記事への反応(0) | 23:11

このエントリーをはてなブックマークに追加ツイートシェア

記事への反応 -

記事への反応(ブックマークコメント)

全てのコメントを見る

人気エントリ

注目エントリ

ログインユーザー登録
ようこそ ゲスト さん
Copyright (C) 2001-2025 hatena. All Rights Reserved.

[8]ページ先頭

©2009-2025 Movatter.jp