Skip to content

Commit 90d0c74

Browse files
author
Kyle Mo
committed
update code to make it work again
1 parent d6d285d commit 90d0c74

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ interface APIResponse {
4242
// Use cheerio to get articles' claps count
4343
slicedData = await Promise.all(
4444
apiResponse.data.items
45-
.filter((item) => item.categories.length !== 0) // filter comment
45+
.filter(item => item.categories.length !== 0) // filter comment
4646
.slice(0, 3) // latest 3 articles
47-
.map(async (item) => {
47+
.map(async item => {
4848
const res = await axios.get(item.guid);
4949
const $ = cheerio.load(res.data);
50-
const text = $('button').text();
50+
const text = $('p.bo > button.au.av').first().text();
5151
let matches = text.match(CLAPS_COUNT_REGEX);
5252
return { title: item.title, claps: matches ? matches[0] : '0' };
5353
})
@@ -59,12 +59,14 @@ interface APIResponse {
5959
// Get user's follower count
6060
const res = await axios.get(MEDIUM_PROFILE_BASE_URL + MEDIUM_USER_NAME);
6161
const $ = cheerio.load(res.data);
62-
const followerCountMatchList = $('a').text().match(FOLLOWERS_COUNT_REGEX);
62+
const followerCountMatchList = $('button')
63+
.text()
64+
.match(FOLLOWERS_COUNT_REGEX);
6365
followerCount = followerCountMatchList
6466
? followerCountMatchList[0]
6567
: '??? Followers';
6668

67-
slicedData.forEach((item) => {
69+
slicedData.forEach(item => {
6870
let trimTitle;
6971
if (item.title.length > MAX_STR_LENGTH)
7072
trimTitle = item.title.slice(0, MAX_STR_LENGTH) + '...';

0 commit comments

Comments
 (0)