If you ever find yourself needing to copy text from facebook groups (for fear of graph auth) for market research or data viz, I wrote a super simple script that you can paste into your console after having visited the group page.
var text = ''
var imgUrls = ''
var scroller = function(by) {
window.scrollBy(0, by)
}
var logText = function() {
document.querySelectorAll('.userContent p').forEach(item => {
text = `${text}\n\n${item.innerText}`
})
document.querySelectorAll('img.img').forEach(item => {
imgUrls = `${imgUrls}\n\n${item.getAttribute('src').split('?')[0]}`
})
console.log(text)
console.log(imgUrls)
}
var startInterval = function(scrollBy, speed, endby) {
var interval = setInterval(() => {
this.scroller(scrollBy)
}, speed*1000)
setTimeout(() => {
clearInterval(interval)
logText()
}, endby*1000)
}
startInterval(5000, 0.5, 30) // will log the text after 30 seconds. Increase to load more
Doesn't seem to work anymore
Wow, this is a great interim solution while we wait on our App approval.
We had a working plugin and we lost it use when they changed the permissions.
One last request, can it also pick up the image urls?
(.. our community is based on showing examples of engine parts )
I can style it all if I had the urls..even if its only the 1 featured image, not the remaining. Thanks in advance, hopefully this thread validates your work to other seeking this type of solution.
@leo2018 sure I've updated it. It's not really a complex solution - entry level js; but might be useful as a chrome plugin; I may look into that.
Thanks for the quick reply, I believe I did the steps properly but no success .... I believe Facebook has truly locked down the group's information, the console did not return anyting.
I'll try again today from another IP and see if I have any luck, thanks again
Hey @leo2018, seems you're half right. They changed the element class names; it's impossible for them to lock it down right now - so long as they're displaying the data - we can get it with javascript :)
All you have to do is replace the 'div[data-ad-preview="message"]' with '.userContent p' now :) Will update it
where are the results stored
Hey @leo2018 the console spits it out after 30s so you can copy and paste it . It will we in the console tab in developer tools if you're using chrome; or any console equivalent in other browsers
has anyone tried this?
Hey @geniouspablo, let me know if you'd like me to explain any parts of the code
yea it's cool! scrolls down page to load as many as you want and then logs them