Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var moment = require('moment');
- var clarinet = require("clarinet")
- , parser = clarinet.parser();
- var request = require("request"),
- cheerio = require("cheerio");
- var mm = moment().locale("id")
- var text1 = "Peristiwa Sejarah\n"+mm.format("DD MMMM");
- function peristiwaHariIni(){
- var url = "http://id.wikipedia.org/wiki/"+mm.format("DD_MMMM");
- console.log(url);
- request(url, function (error, response, body) {
- if (!error) {
- var $ = cheerio.load(body);
- $('#Peristiwa').parent().next().find('li').each(function(){
- item.push({
- "content": $(this).text()
- });
- });
- parser.write(JSON.stringify(item)).close();
- } else {
- console.log("We’ve encountered an error: " + error);
- }
- });
- parser.onvalue = function (v) {
- text1 += v+"\n";
- };
- return text1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement