Skip to content

Instantly share code, notes, and snippets.

@loaiabdalslam
Last active August 26, 2019 03:17
Show Gist options
  • Save loaiabdalslam/15ffeb8c1ca00093f9971ddc19c57eca to your computer and use it in GitHub Desktop.
Save loaiabdalslam/15ffeb8c1ca00093f9971ddc19c57eca to your computer and use it in GitHub Desktop.
Facebook Group Crawling | How to make it ?
/**
## 1 ::Posts on Group :
open group from this link :https://m.facebook.com/groups/892792400815703
**/
// 1- Get All page Posts :
function Posts() {
// @example:
// let posts = new Posts()
// posts.rowData(posts.getbyId(3))
this.array = document.getElementsByClassName('story_body_container')
this.getbyId = function getbyId(i) {
return this.array[i]
}
this.getAll = function() {
return this.array
}
this.rowData = function(object) {
let text = object.innerText
let stripted = text.split('\n')
let username = stripped[0].split('CSE')[0]
let date = stripped[1] // not formated one
let post_content = stripped[2]
return {
name: username,
date: date,
content: post_content]
}
}
}
// 2 - Auto Scroll and Crawling Posts:
function startCrawling() {
var scroll = setInterval(function() {
window.scrollBy(0, 1000); // 1000 or document.body.scrollHeight
}, 2000);
}
// 3 - Stop Interval
function stopCrawling(scroll) {
clearInterval(scroll);
}
/**
## 2 :: Crawling Comments on Posts :
How Much Comment on Post :
1- open post in anthor Tap : https://m.facebook.com/groups/892792400815703?view=permalink&id=2292379994190263&anchor_composer=false&refid=18&_ft_=qid.6729279865617353288%3Amf_story_key.2292379994190263%3Agroup_id.892792400815703%3Atop_level_post_id.2292379994190263%3Atl_objid.2292379994190263%3Acontent_owner_id_new.577340633%3Asrc.22%3Astory_location.6%3Afilter.GroupStoriesByActivityEntQuery&__tn__=%2AW-R
**/
function Comments() {
// @example:
// let comments = new Comments()
// comments.rowData(comments.getbyId(3))
this.array = document.getElementsByClassName('_2a_i')
this.getbyId = function getbyId(i) {
if (typeof this.array[i] == 'undefined') throw ('Where is That index , i cant see it ?')
return this.array[i]
}
this.getAll = function() {
return this.array
}
this.rowData = function(object) {
let text = object.innerText
let stripted = text.split('\n')
let name = stripted[0]
let content = stripted[1]
return {
name: name,
content: content
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment