|
3 | 3 | */
|
4 | 4 |
|
5 | 5 | var xray = require('..');
|
6 |
| -var array = require('array'); |
7 |
| -var fmt = require('util').format; |
8 |
| - |
9 |
| -/** |
10 |
| - * Urls |
11 |
| - */ |
12 |
| - |
13 |
| -var languages = [ |
14 |
| - 'JavaScript', |
15 |
| - 'CSS', |
16 |
| - 'CoffeeScript', |
17 |
| - 'Ruby', |
18 |
| - 'Python', |
19 |
| - 'Shell', |
20 |
| - 'Go', |
21 |
| - 'C', |
22 |
| - 'C++', |
23 |
| - 'Objective-C', |
24 |
| - 'PHP', |
25 |
| - 'VimL', |
26 |
| - 'Java', |
27 |
| - 'Swift', |
28 |
| - 'Scala', |
29 |
| - 'TeX', |
30 |
| - 'Perl', |
31 |
| - 'Lua', |
32 |
| - 'Clojure', |
33 |
| - 'IDL', |
34 |
| - 'Objective-C++', |
35 |
| - 'Processing', |
36 |
| - 'R', |
37 |
| - 'Vala', |
38 |
| - 'Lisp', |
39 |
| - 'XSLT', |
40 |
| - 'LiveScript', |
41 |
| - 'TypeScript' |
42 |
| -]; |
43 |
| - |
44 |
| -/** |
45 |
| - * Get the urls |
46 |
| - */ |
47 |
| - |
48 |
| -var base = 'https://github.com/stars/matthewmueller?direction=%s&language=%s&sort=created'; |
49 |
| -var urls = []; |
50 |
| -languages.forEach(function(language) { |
51 |
| - language = decodeURIComponent(language); |
52 |
| - urls.push(fmt(base, 'asc', language)); |
53 |
| - urls.push(fmt(base, 'desc', language)); |
54 |
| -}) |
55 | 6 |
|
56 | 7 | /**
|
57 | 8 | * Use
|
58 | 9 | */
|
59 | 10 |
|
60 |
| -xray(urls) |
61 |
| - .key('repo', 'div > ul > li.repo-list-item.public.source > h3.repo-list-name > a') |
62 |
| - .key('url', 'div > ul > li.repo-list-item.public.source > h3.repo-list-name > a', 'href') |
63 |
| - .key('author', 'ul > li.repo-list-item.public.source > h3.repo-list-name > a > span.prefix') |
64 |
| - .key('description', 'div > div > ul > li > p.repo-list-description') |
65 |
| - .key('time', '.repo-list-meta time', 'datetime') |
66 |
| - .paginate('div.pagination > a:last-child') |
67 |
| - .json(function(err, json) { |
| 11 | +xray('https://github.com/stars/matthewmueller') |
| 12 | + .select([{ |
| 13 | + $root: '.repo-list-item', |
| 14 | + link: '.repo-list-name a[href]' |
| 15 | + }]) |
| 16 | + .paginate('div.pagination > a:last-child[href]') |
| 17 | + .limit(3) |
| 18 | + .run(function(err, json) { |
68 | 19 | if (err) throw err;
|
69 |
| - json = array(json).unique('repo').toArray(); |
70 | 20 | console.log(JSON.stringify(json, true, 2));
|
71 | 21 | })
|
0 commit comments