Skip to content

Added claps in scraper #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 73 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ medium-scrapper allows for you to scrape latests article from a user

### Example
```javascript
scraper = require('medium-scraper');
scraper = require("medium-scraper");

var medium = {user: '@nearbycoder'}
var medium = {user: "@nearbycoder"}

scraper.getPosts(medium).then(function(results) {
console.log(results)
Expand All @@ -21,54 +21,76 @@ medium-scrapper allows for you to scrape latests article from a user

### Results
```json
[
{
"title":"We’re Presenting at Tulsa TechFest",
"time":"Jul 22, 2016",
"image":"https://cdn-images-1.medium.com/max/900/0*ZFgMpOUO0KV0KXuL.jpg",
"url":"https://medium.com/made-by-munsters/were-presenting-at-tulsa-techfest-682efde980d9"
},
{
"title":"Ruby Remote Conf Recap",
"time":"Jul 1, 2016",
"image":"https://cdn-images-1.medium.com/max/900/0*qOVLWAPfZPY6bNcF.png",
"url":"https://medium.com/made-by-munsters/ruby-remote-conf-recap-c87f00c05db2"
},
{
"title":"Getting Around API Rate Limiting",
"time":"May 19, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/getting-around-api-rate-limiting-642b7790b225"
},
{
"title":"Welcome Back TulsaJS",
"time":"May 11, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/welcome-back-tulsajs-cd73fec008ac"
},
{
"title":"Writing Angular with Webpack and es6",
"time":"Apr 14, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/writing-angular-with-webpack-and-es6-e84cc668f827"
},
{
"title":"Authorizing Trello Integration with Angular",
"time":"Apr 5, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/authorizing-trello-integration-with-angular-13eb6b85de88"
},
{
"title":"Commit with Intent",
"time":"Mar 15, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/commit-with-intent-b0bb67bea50a"
},
{
"title":"How I learned failure as a developer",
"time":"Jan 12, 2016",
"image":null,
"url":"https://medium.com/@nearbycoder/how-i-learned-failure-as-a-developer-94429e4a971c"
}
[
{
"title":"How To Start a Pair Programming Routine",
"time":"Jun 26, 2017",
"image":"https://cdn-images-1.medium.com/max/900/1*oIhBCXd78UWsbA0T2EVApQ.jpeg",
"url":"https://medium.com/made-by-munsters/how-to-start-a-pair-programming-routine-3d51a349dcd3",
"claps":"1"
},
{
"title":"",
"time":"May 24, 2017",
"image":"https://cdn-images-1.medium.com/max/900/1*rVK1L0kH1ABLvtY2Z0qIDg.jpeg",
"url":"https://medium.com/made-by-munsters/automate-your-slack-status-612087714d3b",
"claps":"12"
},
{
"title":"We’re Presenting at Tulsa TechFest",
"time":"Jul 22, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/were-presenting-at-tulsa-techfest-682efde980d9",
"claps":"1"
},
{
"title":"",
"time":"Jul 1, 2016",
"image":"https://cdn-images-1.medium.com/max/900/0*qOVLWAPfZPY6bNcF.png",
"url":"https://medium.com/made-by-munsters/ruby-remote-conf-recap-c87f00c05db2",
"claps":"2"
},
{
"title":"Getting Around API Rate Limiting",
"time":"May 19, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/getting-around-api-rate-limiting-642b7790b225",
"claps":"1"
},
{
"title":"Welcome Back TulsaJS",
"time":"May 11, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/welcome-back-tulsajs-cd73fec008ac",
"claps":"1"
},
{
"title":"Writing Angular with Webpack and es6",
"time":"Apr 14, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/writing-angular-with-webpack-and-es6-e84cc668f827",
"claps":"3"
},
{
"title":"",
"time":"Apr 5, 2016",
"image":"https://cdn-images-1.medium.com/max/900/1*3jXyhPHEuXR4kTcaJmoBVQ.jpeg",
"url":"https://medium.com/made-by-munsters/authorizing-trello-integration-with-angular-13eb6b85de88",
"claps":"1"
},
{
"title":"Commit with Intent",
"time":"Mar 15, 2016",
"image":null,
"url":"https://medium.com/made-by-munsters/commit-with-intent-b0bb67bea50a",
"claps":"1"
},
{
"title":"How I learned failure as a developer",
"time":"Jan 12, 2016",
"image":null,
"url":"https://medium.com/@nearbycoder/how-i-learned-failure-as-a-developer-94429e4a971c",
"claps":"2"
}
]
```
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ function getPosts(medium) {
$('.streamItem--postPreview').each(function(index, article) {
var image = $(article).find('.graf-image').first().data('image-id');
posts[index] = {
title: $(article).find('.graf--leading').text(),
title: $(article).find('.graf--title').text(),
time: $(article).find('time').text(),
image: image ? `https://cdn-images-1.medium.com/max/900/${image}` : null,
url: $(article).find('.postArticle-readMore').find('a').attr('href').split('?')[0]
url: $(article).find('.postArticle-readMore').find('a').attr('href').split('?')[0],
claps: $(article).find('.postArticle').find('.multirecommend').find('span').find('.button').text()

}
})
posts.success = true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-scraper",
"version": "0.0.1",
"version": "0.0.2",
"description": "Allows for scrapping medium latest posts",
"main": "index.js",
"scripts": {
Expand Down