Skip to content

Commit

Permalink
Basic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jt3k committed May 11, 2020
1 parent 3248163 commit 8cc14dc
Show file tree
Hide file tree
Showing 4 changed files with 416 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env node
const getVkPics = require('.');

// Specific to my own environment
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

// USAGE
const urls = process.argv.slice(2);
(async () => {
const output = await Promise.all(urls.map(getVkPics));
console.log(output);
})();

15 changes: 15 additions & 0 deletions get-vk-pics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const cheerio = require("cheerio");
const got = require("got");

module.exports = async function getVkPics(url) {
const { body } = await got.get(url);
const $ = cheerio.load(body);
let posts = $('[class="wall_item"]').toArray();
return posts.map((item) => {
const post = $(item);
const pic = post.find("[data-src_big]").attr("data-src_big");
const [picUrl, picHeight, picWidth] = pic.split("|");
const likes = post.find(".v_like").text();
return { likes, picUrl, picWidth, picHeight };
});
};
364 changes: 364 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8cc14dc

Please sign in to comment.