Skip to content

Instantly share code, notes, and snippets.

@fiatjaf
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiatjaf/10605200 to your computer and use it in GitHub Desktop.
Save fiatjaf/10605200 to your computer and use it in GitHub Desktop.
garimpador de posts do olavo de carvalho
// jquery
window.posts = {}
var fetch = function () {
$('div[role="article"] span.fcg span.fwb a[href^="https://www.facebook.com/olavo.decarvalho"]').each(function () {
var post = {}
var elem = $(this).closest('div[role="article"]')
if (!elem) return
post.url = elem.find('a.uiLinkSubtle').attr('href')
if (!post.url) return
post.id = post.url.split('/').slice(-1)[0].split('?')[0]
post.date = elem.find('a.uiLinkSubtle abbr').attr('title')
if (!post.date) return
post.utime = elem.find('a.uiLinkSubtle abbr').data('utime')
if (!post.utime) return
post.text = elem.find('div.userContentWrapper').text()
if (!post.text) return
window.posts[post.id] = post
console.log('fetched post ' + post.id)
})
}
var scroll = function () {
window.scrollTo(0, document.body.scrollHeight)
}
var download = function () {
var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(window.posts))
$('<a id="download-json" href="data:' + data + '" download="data.json">download JSON</a>').appendTo(document.body)
$('#download-json').click()
}
window.count = 0
var main = function () {
scroll()
setTimeout(function () {
main()
window.count++
}, 4500)
if (window.count > 150) {
fetch()
download()
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment