codementor 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +14 -131
- package/lib/index.js +129 -160
- package/package.json +3 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2016-
|
|
3
|
+
Copyright (c) 2016-26 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,55 +1,15 @@
|
|
|
1
1
|
<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
3
|
# codementor
|
|
21
4
|
|
|
22
|
-
[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [](https://github.com/IonicaBizau/ama) [](https://www.npmjs.com/package/codementor) [](https://www.npmjs.com/package/codementor) [](https://www.codementor.io
|
|
5
|
+
[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [](https://github.com/IonicaBizau/ama) [](https://www.npmjs.com/package/codementor) [](https://www.npmjs.com/package/codementor) [](https://www.codementor.io/@johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
|
|
23
6
|
|
|
24
7
|
<a href="https://www.buymeacoffee.com/H96WwChMy" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
|
|
25
8
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
9
|
> A scraper for codementor.io.
|
|
33
10
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
11
|
> :bulb: **Hey!** If you need help with JavaScript/CSS/HTML/Git & GitHub, [ping me on CodeMentor](https://www.codementor.io/johnnyb).
|
|
40
12
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
13
|
## :cloud: Installation
|
|
54
14
|
|
|
55
15
|
```sh
|
|
@@ -60,22 +20,8 @@ npm install --save codementor
|
|
|
60
20
|
yarn add codementor
|
|
61
21
|
```
|
|
62
22
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
23
|
## :clipboard: Example
|
|
76
24
|
|
|
77
|
-
|
|
78
|
-
|
|
79
25
|
```js
|
|
80
26
|
const CodeMentor = require("codementor");
|
|
81
27
|
|
|
@@ -150,38 +96,12 @@ CodeMentor.mentorProfile("johnnyb", (err, { data }) => {
|
|
|
150
96
|
});
|
|
151
97
|
```
|
|
152
98
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
## :question: Get Help
|
|
164
|
-
|
|
165
|
-
There are few ways to get help:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
|
|
170
|
-
2. For bug reports and feature requests, open issues. :bug:
|
|
171
|
-
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
99
|
## :memo: Documentation
|
|
178
100
|
|
|
179
|
-
|
|
180
101
|
### `userUrl(user)`
|
|
181
102
|
Returns the user profile url.
|
|
182
103
|
|
|
183
104
|
#### Params
|
|
184
|
-
|
|
185
105
|
- **String** `user`: The CodeMentor username.
|
|
186
106
|
|
|
187
107
|
#### Return
|
|
@@ -191,7 +111,6 @@ Returns the user profile url.
|
|
|
191
111
|
Scrapes the mentor profile.
|
|
192
112
|
|
|
193
113
|
#### Params
|
|
194
|
-
|
|
195
114
|
- **String** `user`: The CodeMentor username.
|
|
196
115
|
- **Function** `cb`: The callback function.
|
|
197
116
|
|
|
@@ -202,80 +121,44 @@ Scrapes the mentor profile.
|
|
|
202
121
|
Gets the mentor reviews.
|
|
203
122
|
|
|
204
123
|
#### Params
|
|
205
|
-
|
|
206
124
|
- **String** `user`: The CodeMentor username.
|
|
207
125
|
- **Function** `cb`: The callback function.
|
|
208
126
|
|
|
209
127
|
#### Return
|
|
210
128
|
- **Promise** A promise object.
|
|
211
129
|
|
|
130
|
+
## :question: Get Help
|
|
212
131
|
|
|
132
|
+
There are a few ways to get help:
|
|
213
133
|
|
|
134
|
+
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long as you add a link to your Stack Overflow question.
|
|
135
|
+
2. For bug reports and feature requests, open issues. :bug:
|
|
136
|
+
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
214
137
|
|
|
138
|
+
## :yum: How to Contribute
|
|
215
139
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
## :yum: How to contribute
|
|
226
140
|
Have an idea? Found a bug? See [how to contribute][contributing].
|
|
227
141
|
|
|
142
|
+
## :sparkling_heart: Support My Projects
|
|
228
143
|
|
|
229
|
-
|
|
230
|
-
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
|
|
231
|
-
this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
|
|
232
|
-
|
|
233
|
-
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
|
|
144
|
+
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute it (even resell it).
|
|
234
145
|
|
|
146
|
+
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are a few ways you can do it:
|
|
235
147
|
|
|
236
148
|
- Starring and sharing the projects you like :rocket:
|
|
237
|
-
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you
|
|
149
|
+
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you for years if you buy me one. :grin: :book:
|
|
238
150
|
- [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
|
|
239
151
|
- [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
|
|
240
|
-
- **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
241
|
-
|
|
242
|
-

|
|
152
|
+
- **Bitcoin**—You can send me bitcoins at this address (or by scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
243
153
|
|
|
154
|
+

|
|
244
155
|
|
|
245
156
|
Thanks! :heart:
|
|
246
157
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
158
|
## :scroll: License
|
|
271
159
|
|
|
272
160
|
[MIT][license] © [Ionică Bizău][website]
|
|
273
161
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
162
|
[license]: /LICENSE
|
|
280
163
|
[website]: https://ionicabizau.net
|
|
281
164
|
[contributing]: /CONTRIBUTING.md
|
|
@@ -285,5 +168,5 @@ Thanks! :heart:
|
|
|
285
168
|
[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
|
|
286
169
|
[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
|
|
287
170
|
[patreon]: https://www.patreon.com/ionicabizau
|
|
288
|
-
[amazon]:
|
|
171
|
+
[amazon]: https://amzn.eu/hRo9sIZ
|
|
289
172
|
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
|
package/lib/index.js
CHANGED
|
@@ -1,175 +1,144 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const scrape = require("scrape-it")
|
|
4
|
+
, match = require("match-it")
|
|
5
|
+
, splitByComma = require("split-by-comma")
|
|
6
|
+
;
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
const CODEMENTOR_HOST = "https://www.codementor.io/"
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
module.exports = class CodeMentor {
|
|
11
|
+
/**
|
|
12
|
+
* userUrl
|
|
13
|
+
* Returns the user profile url.
|
|
14
|
+
*
|
|
15
|
+
* @name userUrl
|
|
16
|
+
* @function
|
|
17
|
+
* @param {String} user The CodeMentor username.
|
|
18
|
+
* @returns {String} The user profile url.
|
|
19
|
+
*/
|
|
20
|
+
static userUrl (user) {
|
|
21
|
+
return CODEMENTOR_HOST + "@" +user;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
24
|
+
/**
|
|
25
|
+
* mentorProfile
|
|
26
|
+
* Scrapes the mentor profile.
|
|
27
|
+
*
|
|
28
|
+
* @name mentorProfile
|
|
29
|
+
* @function
|
|
30
|
+
* @param {String} user The CodeMentor username.
|
|
31
|
+
* @param {Function} cb The callback function.
|
|
32
|
+
* @returns {Promise} A promise object.
|
|
33
|
+
*/
|
|
34
|
+
static mentorProfile (user, cb) {
|
|
35
|
+
debugger
|
|
36
|
+
return scrape(CodeMentor.userUrl(user), {
|
|
37
|
+
reviews: {
|
|
38
|
+
listItem: "[class^='Review__StyledReview']"
|
|
39
|
+
, data: {
|
|
40
|
+
avatar: {
|
|
41
|
+
selector: ".cui-avatar-image > img"
|
|
42
|
+
, attr: "src"
|
|
43
|
+
}
|
|
44
|
+
, content: ".content"
|
|
45
|
+
, name: {
|
|
46
|
+
selector: ".name"
|
|
47
|
+
, eq: 0
|
|
48
|
+
}
|
|
49
|
+
, date: ".time"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
, description: ".headline"
|
|
53
|
+
, timezone: {
|
|
54
|
+
selector: ".timezone"
|
|
55
|
+
, how: "text"
|
|
56
|
+
}
|
|
57
|
+
, languages: {
|
|
58
|
+
selector: ".additional-info .languages > span:nth-child(2n)"
|
|
59
|
+
, convert: splitByComma
|
|
60
|
+
}
|
|
61
|
+
, skills: {
|
|
62
|
+
listItem: ".badge.customizeBadge"
|
|
63
|
+
}
|
|
64
|
+
, ratings: {
|
|
65
|
+
selector: ".review-stats .span8 .distribution-row .span3.muted"
|
|
66
|
+
, data: {
|
|
67
|
+
five: {
|
|
68
|
+
eq: 0
|
|
69
|
+
, convert: Number
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
selector: ".timezone",
|
|
68
|
-
how: "text"
|
|
69
|
-
},
|
|
70
|
-
languages: {
|
|
71
|
-
selector: ".additional-info .languages > span:nth-child(2n)",
|
|
72
|
-
convert: splitByComma
|
|
73
|
-
},
|
|
74
|
-
skills: {
|
|
75
|
-
listItem: ".badge.customizeBadge"
|
|
76
|
-
},
|
|
77
|
-
ratings: {
|
|
78
|
-
selector: ".review-stats .span8 .distribution-row .span3.muted",
|
|
79
|
-
data: {
|
|
80
|
-
five: {
|
|
81
|
-
eq: 0,
|
|
82
|
-
convert: Number
|
|
83
|
-
},
|
|
84
|
-
four: {
|
|
85
|
-
eq: 1,
|
|
86
|
-
convert: Number
|
|
87
|
-
},
|
|
88
|
-
three: {
|
|
89
|
-
eq: 2,
|
|
90
|
-
convert: Number
|
|
91
|
-
},
|
|
92
|
-
two: {
|
|
93
|
-
eq: 3,
|
|
94
|
-
convert: Number
|
|
95
|
-
},
|
|
96
|
-
one: {
|
|
97
|
-
eq: 4,
|
|
98
|
-
convert: Number
|
|
99
|
-
}
|
|
71
|
+
, four: {
|
|
72
|
+
eq: 1
|
|
73
|
+
, convert: Number
|
|
100
74
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
rate: {
|
|
105
|
-
selector: ".topCard > .price > strong",
|
|
106
|
-
convert: function convert(x) {
|
|
107
|
-
return parseFloat(x.substring(1));
|
|
75
|
+
, three: {
|
|
76
|
+
eq: 2
|
|
77
|
+
, convert: Number
|
|
108
78
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
convert: function convert(x) {
|
|
113
|
-
return parseFloat(x.substring(1)) * 4;
|
|
79
|
+
, two: {
|
|
80
|
+
eq: 3
|
|
81
|
+
, convert: Number
|
|
114
82
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
convert: Number
|
|
119
|
-
},
|
|
120
|
-
sessionCount: {
|
|
121
|
-
selector: ".sessionGiven",
|
|
122
|
-
convert: function convert(x) {
|
|
123
|
-
return +match(x, /([0-9]+) sessions given/)[1];
|
|
83
|
+
, one: {
|
|
84
|
+
eq: 4
|
|
85
|
+
, convert: Number
|
|
124
86
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
, name: ".pageTitle"
|
|
90
|
+
, about: ".about"
|
|
91
|
+
, rate: {
|
|
92
|
+
selector: ".topCard > .price > strong"
|
|
93
|
+
, convert: x => parseFloat(x.substring(1))
|
|
94
|
+
}
|
|
95
|
+
, hourRate: {
|
|
96
|
+
selector: ".topCard > .price > strong"
|
|
97
|
+
, convert: x => parseFloat(x.substring(1)) * 4
|
|
98
|
+
}
|
|
99
|
+
, averateRating: {
|
|
100
|
+
selector: ".topCard > strong"
|
|
101
|
+
, convert: Number
|
|
102
|
+
}
|
|
103
|
+
, sessionCount: {
|
|
104
|
+
selector: ".sessionGiven"
|
|
105
|
+
, convert: x => +match(x, /([0-9]+) sessions given/)[1]
|
|
106
|
+
}
|
|
107
|
+
, signUpDate: {
|
|
108
|
+
selector: ".sessionGiven"
|
|
109
|
+
, convert: x => new Date(match(x, /since (.*)/)[1])
|
|
110
|
+
}
|
|
111
|
+
, responseTime: ".mentor-response .avg-time .good.num"
|
|
112
|
+
, likehoodOfReply: ".mentor-response .rate .good.num"
|
|
113
|
+
, expertise: {
|
|
114
|
+
listItem: ".skillModule"
|
|
115
|
+
, data: {
|
|
116
|
+
name: ".skillName"
|
|
117
|
+
, years_experience: {
|
|
118
|
+
selector: ".skillYear"
|
|
119
|
+
, convert: x => +match(x, /(\d+)/)[1]
|
|
130
120
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
listItem: ".skillModule",
|
|
136
|
-
data: {
|
|
137
|
-
name: ".skillName",
|
|
138
|
-
years_experience: {
|
|
139
|
-
selector: ".skillYear",
|
|
140
|
-
convert: function convert(x) {
|
|
141
|
-
return +match(x, /(\d+)/)[1];
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
description: ".description",
|
|
145
|
-
tags: {
|
|
146
|
-
listItem: ".tags",
|
|
147
|
-
how: "text"
|
|
148
|
-
}
|
|
121
|
+
, description: ".description"
|
|
122
|
+
, tags: {
|
|
123
|
+
listItem: ".tags"
|
|
124
|
+
, how: "text"
|
|
149
125
|
}
|
|
150
126
|
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* mentorReviews
|
|
156
|
-
* Gets the mentor reviews.
|
|
157
|
-
*
|
|
158
|
-
* @name mentorReviews
|
|
159
|
-
* @function
|
|
160
|
-
* @param {String} user The CodeMentor username.
|
|
161
|
-
* @param {Function} cb The callback function.
|
|
162
|
-
* @returns {Promise} A promise object.
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
}, {
|
|
166
|
-
key: "mentorReviews",
|
|
167
|
-
value: function mentorReviews(user, cb) {
|
|
168
|
-
return CodeMentor.mentorProfile(user, function (err, data) {
|
|
169
|
-
return cb(err, data && data.reviews);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}]);
|
|
127
|
+
}
|
|
128
|
+
}, cb);
|
|
129
|
+
}
|
|
173
130
|
|
|
174
|
-
|
|
175
|
-
|
|
131
|
+
/**
|
|
132
|
+
* mentorReviews
|
|
133
|
+
* Gets the mentor reviews.
|
|
134
|
+
*
|
|
135
|
+
* @name mentorReviews
|
|
136
|
+
* @function
|
|
137
|
+
* @param {String} user The CodeMentor username.
|
|
138
|
+
* @param {Function} cb The callback function.
|
|
139
|
+
* @returns {Promise} A promise object.
|
|
140
|
+
*/
|
|
141
|
+
static mentorReviews (user, cb) {
|
|
142
|
+
return CodeMentor.mentorProfile(user, (err, data) => cb(err, data && data.reviews));
|
|
143
|
+
}
|
|
144
|
+
};
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"io"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.0.
|
|
12
|
+
"version": "2.0.2",
|
|
13
13
|
"main": "lib/index.js",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"menu/",
|
|
40
40
|
"cli.js",
|
|
41
41
|
"index.js",
|
|
42
|
+
"index.d.ts",
|
|
42
43
|
"bloggify.js",
|
|
43
44
|
"bloggify.json",
|
|
44
45
|
"bloggify/"
|
|
@@ -52,4 +53,4 @@
|
|
|
52
53
|
"example": "example"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {}
|
|
55
|
-
}
|
|
56
|
+
}
|