Skip to content

Commit b0529b7

Browse files
update example
1 parent eb766b0 commit b0529b7

File tree

1 file changed

+8
-58
lines changed

1 file changed

+8
-58
lines changed

examples/github-stars.js

Lines changed: 8 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,19 @@
33
*/
44

55
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-
})
556

567
/**
578
* Use
589
*/
5910

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) {
6819
if (err) throw err;
69-
json = array(json).unique('repo').toArray();
7020
console.log(JSON.stringify(json, true, 2));
7121
})

0 commit comments

Comments
 (0)