| | 16 | |
| | 17 | == Sample == |
| | 18 | {{{ |
| | 19 | var jscr = new JSAutoPageScraper('http://twitter.com/home', { |
| | 20 | nextLink : '//div[@class="pagination"]/a[last()]', |
| | 21 | paragraph : '//*[contains(@class,"hentry")]', |
| | 22 | mapping : { |
| | 23 | link : './/*[@class="meta entry-meta"]/a[contains(@class,"entry-date")]/@href', |
| | 24 | author : './/td[contains(@class,"content")]/strong/a/text()', |
| | 25 | content : function(p) { (p.textContent || p.innerText).replace(/\s+/g, ' '); } |
| | 26 | } |
| | 27 | }); |
| | 28 | |
| | 29 | jscr.scrape(5, callback1) |
| | 30 | .skip(5) |
| | 31 | .scrape(10, callback2) |
| | 32 | .wait(); |
| | 33 | |
| | 34 | function callback1(records) { ... } |
| | 35 | function callback2(records) { |
| | 36 | ... |
| | 37 | jscr.done(); |
| | 38 | } |
| | 39 | |
| | 40 | }}} |