Last active
December 26, 2015 04:25
-
-
Save betzerra/7c7074d94c49d778c47b to your computer and use it in GitHub Desktop.
Muestra las últimas noticias en medios argentinos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
casperjs tn_news.js | |
./rss_news.rb http://www.clarin.com/rss/lo-ultimo/ Clarin | |
./rss_news.rb http://contenidos.lanacion.com.ar/herramientas/rss-origen=2 LaNacion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rss' | |
require 'open-uri' | |
require 'sanitize' | |
url = ARGV[0] | |
open(url) do |rss| | |
feed = RSS::Parser.parse(rss) | |
feed.items.each do |item| | |
title = Sanitize.fragment(item.title) | |
puts "##{ARGV[1]} - #{title}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Muestra las noticias destacadas de TN | |
* | |
* casperjs tn_news.js | |
* casperjs tn_news.js | grep Tinelli -> Muestra las noticias importantes | |
*/ | |
var casper = require('casper').create({ | |
waitTimeout: 10000, | |
pageSettings: { | |
loadImages: false, | |
loadPlugins: false | |
}, | |
viewportSize: { | |
height: 1000, | |
width: 1024 | |
} | |
}); | |
var baseUrl = "http://www.tn.com.ar"; | |
function loadNews(){ | |
casper.then(function() { | |
var mainHeadlineH1 = this.evaluate(function() { | |
return document.querySelector('h1').textContent.trim(); | |
}); | |
var mainHeadlineH2 = this.evaluate(function() { | |
return document.querySelector('h2').textContent.trim().substring(0,100) + "..."; | |
}); | |
console.log("#TN - " + mainHeadlineH1 + " - " + mainHeadlineH2); | |
var featuredNews = this.evaluate(function() { | |
var news = document.querySelectorAll('h2.heading'); | |
return Array.prototype.map.call(news, function(e) { | |
return e.textContent.trim(); | |
}); | |
}); | |
for (var i = 0; i < featuredNews.length; i++) { | |
console.log("#TN - " + featuredNews[i]); | |
} | |
}); | |
} | |
casper.start(baseUrl, loadNews); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment