From 1ca8c3641ada97f0a7661afc773e3cdd02766426 Mon Sep 17 00:00:00 2001 From: ilyasx Date: Sun, 9 Jul 2017 23:45:30 +0500 Subject: [PATCH] updated --- Database/fb_data.sql | 158 +++++++++++++++++++++++--------- Database/fb_data.sql~ | 203 ++++++++++++++++++++++++++++++++++++++++++ README.md | 16 +++- config.py | 14 +-- group_functions.py | 33 +++++++ 5 files changed, 376 insertions(+), 48 deletions(-) create mode 100644 Database/fb_data.sql~ diff --git a/Database/fb_data.sql b/Database/fb_data.sql index 768d2e9..57d90be 100644 --- a/Database/fb_data.sql +++ b/Database/fb_data.sql @@ -1,32 +1,58 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net +-- MySQL dump 10.13 Distrib 5.6.31, for debian-linux-gnu (x86_64) -- --- Host: localhost --- Generation Time: Jun 06, 2016 at 05:36 AM --- Server version: 5.5.47-0ubuntu0.14.04.1 --- PHP Version: 5.5.9-1ubuntu4.14 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - +-- Host: localhost Database: fb_data +-- ------------------------------------------------------ +-- Server version 5.6.31-0ubuntu0.15.10.1 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `Posts` +-- + +DROP TABLE IF EXISTS `Posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `Posts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `pageid` varchar(200) NOT NULL, + `postid` varchar(200) NOT NULL, + `message` varchar(10000) NOT NULL, + `fromid` varchar(100) NOT NULL, + `fromname` varchar(100) NOT NULL, + `createdtime` varchar(50) NOT NULL, + `total_likes` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Database: `fb_data` +-- Dumping data for table `Posts` -- --- -------------------------------------------------------- +LOCK TABLES `Posts` WRITE; +/*!40000 ALTER TABLE `Posts` DISABLE KEYS */; +/*!40000 ALTER TABLE `Posts` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `comments` -- -CREATE TABLE IF NOT EXISTS `comments` ( +DROP TABLE IF EXISTS `comments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `comments` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pageid` varchar(200) NOT NULL, @@ -38,15 +64,53 @@ CREATE TABLE IF NOT EXISTS `comments` ( `createdtime` varchar(50) NOT NULL, `total_likes` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `comments` +-- + +LOCK TABLES `comments` WRITE; +/*!40000 ALTER TABLE `comments` DISABLE KEYS */; +/*!40000 ALTER TABLE `comments` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `images` +-- + +DROP TABLE IF EXISTS `images`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `images` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `source_id` varchar(100) DEFAULT NULL, + `post_id` varchar(100) DEFAULT NULL, + `src` varchar(100) DEFAULT NULL, + `width` varchar(10) DEFAULT NULL, + `height` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `images` +-- --- -------------------------------------------------------- +LOCK TABLES `images` WRITE; +/*!40000 ALTER TABLE `images` DISABLE KEYS */; +/*!40000 ALTER TABLE `images` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `likes` -- -CREATE TABLE IF NOT EXISTS `likes` ( +DROP TABLE IF EXISTS `likes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `likes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pageid` varchar(200) NOT NULL, @@ -56,34 +120,26 @@ CREATE TABLE IF NOT EXISTS `likes` ( `fromname` varchar(200) NOT NULL, `fromid` varchar(200) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Posts` +-- Dumping data for table `likes` -- -CREATE TABLE IF NOT EXISTS `Posts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `pageid` varchar(200) NOT NULL, - `postid` varchar(200) NOT NULL, - `message` varchar(10000) NOT NULL, - `fromid` varchar(100) NOT NULL, - `fromname` varchar(100) NOT NULL, - `createdtime` varchar(50) NOT NULL, - `total_likes` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- +LOCK TABLES `likes` WRITE; +/*!40000 ALTER TABLE `likes` DISABLE KEYS */; +/*!40000 ALTER TABLE `likes` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `replys` -- -CREATE TABLE IF NOT EXISTS `replys` ( +DROP TABLE IF EXISTS `replys`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `replys` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pageid` varchar(200) NOT NULL, @@ -96,23 +152,45 @@ CREATE TABLE IF NOT EXISTS `replys` ( `createdtime` varchar(50) NOT NULL, `total_likes` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; --- -------------------------------------------------------- +/*!40000 ALTER TABLE `replys` ENABLE KEYS */; +UNLOCK TABLES; -- -- Table structure for table `status` -- -CREATE TABLE IF NOT EXISTS `status` ( +DROP TABLE IF EXISTS `status`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `status` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `pageid` varchar(50) NOT NULL, `next` varchar(1000) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `pageid` (`pageid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `status` +-- + +LOCK TABLES `status` WRITE; +/*!40000 ALTER TABLE `status` DISABLE KEYS */; +/*!40000 ALTER TABLE `status` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2017-07-09 22:54:36 diff --git a/Database/fb_data.sql~ b/Database/fb_data.sql~ new file mode 100644 index 0000000..5db725a --- /dev/null +++ b/Database/fb_data.sql~ @@ -0,0 +1,203 @@ +-- MySQL dump 10.13 Distrib 5.6.31, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: fb_data +-- ------------------------------------------------------ +-- Server version 5.6.31-0ubuntu0.15.10.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `Posts` +-- + +DROP TABLE IF EXISTS `Posts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `Posts` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `pageid` varchar(200) NOT NULL, + `postid` varchar(200) NOT NULL, + `message` varchar(10000) NOT NULL, + `fromid` varchar(100) NOT NULL, + `fromname` varchar(100) NOT NULL, + `createdtime` varchar(50) NOT NULL, + `total_likes` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `Posts` +-- + +LOCK TABLES `Posts` WRITE; +/*!40000 ALTER TABLE `Posts` DISABLE KEYS */; +/*!40000 ALTER TABLE `Posts` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `comments` +-- + +DROP TABLE IF EXISTS `comments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `comments` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `pageid` varchar(200) NOT NULL, + `postid` varchar(200) NOT NULL, + `commentid` varchar(200) NOT NULL, + `message` varchar(10000) NOT NULL, + `fromid` varchar(100) NOT NULL, + `fromname` varchar(100) NOT NULL, + `createdtime` varchar(50) NOT NULL, + `total_likes` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `comments` +-- + +LOCK TABLES `comments` WRITE; +/*!40000 ALTER TABLE `comments` DISABLE KEYS */; +/*!40000 ALTER TABLE `comments` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `images` +-- + +DROP TABLE IF EXISTS `images`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `images` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `source_id` varchar(100) DEFAULT NULL, + `post_id` varchar(100) DEFAULT NULL, + `src` varchar(100) DEFAULT NULL, + `width` varchar(10) DEFAULT NULL, + `height` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `images` +-- + +LOCK TABLES `images` WRITE; +/*!40000 ALTER TABLE `images` DISABLE KEYS */; +/*!40000 ALTER TABLE `images` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `likes` +-- + +DROP TABLE IF EXISTS `likes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `likes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `pageid` varchar(200) NOT NULL, + `postid` varchar(200) NOT NULL, + `commentid` varchar(200) DEFAULT NULL, + `replyid` varchar(200) DEFAULT NULL, + `fromname` varchar(200) NOT NULL, + `fromid` varchar(200) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `likes` +-- + +LOCK TABLES `likes` WRITE; +/*!40000 ALTER TABLE `likes` DISABLE KEYS */; +/*!40000 ALTER TABLE `likes` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `replys` +-- + +DROP TABLE IF EXISTS `replys`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `replys` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `pageid` varchar(200) NOT NULL, + `postid` varchar(200) NOT NULL, + `commentid` varchar(200) NOT NULL, + `replyid` varchar(200) NOT NULL, + `message` varchar(10000) NOT NULL, + `fromid` varchar(100) NOT NULL, + `fromname` varchar(100) NOT NULL, + `createdtime` varchar(50) NOT NULL, + `total_likes` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `replys` +-- + +LOCK TABLES `replys` WRITE; +/*!40000 ALTER TABLE `replys` DISABLE KEYS */; +INSERT INTO `replys` VALUES (1,'2017-07-09 13:44:12','165861103465048','165861103465048_1585938494790628','1586014111449733','1586014894782988','Yes..','10203303503625871','Urooj Fatima','2017-07-08T14:49:43+0000',1),(2,'2017-07-09 13:44:13','165861103465048','165861103465048_1585938494790628','1586014111449733','1586016394782838','Jackpot','691401031046384','Sannia Shahani','2017-07-08T14:50:58+0000',1),(3,'2017-07-09 13:44:14','165861103465048','165861103465048_1585938494790628','1586014111449733','1586022718115539','Very true..','10203303503625871','Urooj Fatima','2017-07-08T14:57:52+0000',1),(4,'2017-07-09 13:44:28','165861103465048','165861103465048_1583474548370356','1583478445036633','1583482185036259','Delicious.','1433946840020680','Mufti Faisal Japanwala','2017-07-06T19:39:25+0000',0),(5,'2017-07-09 13:44:29','165861103465048','165861103465048_1583474548370356','1583478445036633','1583482938369517','wait aray XD ap to woh ho jinhonay nay ghamidi ulama ki nazar mai likhi hai XD','1487338351318434','Yusha Mohammad Qureshi','2017-07-06T19:40:05+0000',0),(6,'2017-07-09 13:44:29','165861103465048','165861103465048_1583474548370356','1583478445036633','1583484918369319','maine woh interview daikha jis mai purple phaina hua hai apnay XD mai hans ta he rehgaya, good luck with your work and life, i think i will buy the book.','1487338351318434','Yusha Mohammad Qureshi','2017-07-06T19:41:45+0000',0),(7,'2017-07-09 13:44:32','165861103465048','165861103465048_1583474548370356','1583480755036402','1583482181702926','Yummy','1433946840020680','Mufti Faisal Japanwala','2017-07-06T19:39:25+0000',0),(8,'2017-07-09 13:44:34','165861103465048','165861103465048_1583474548370356','1583485061702638','1583996184984859','1999','1433946840020680','Mufti Faisal Japanwala','2017-07-07T03:07:53+0000',0),(9,'2017-07-09 13:44:39','165861103465048','165861103465048_1586246771426467','1586261988091612','1586868604697617','Jani chalo steak looks amazing','10156369462604689','Ahmed Qureshi','2017-07-09T07:59:06+0000',0),(10,'2017-07-09 13:44:42','165861103465048','165861103465048_1586246771426467','1586287964755681','1586454068072404','Ahaahhaha Talha siddiqui reviews aarahy kal ki discussion k bad se','10210017975594456','Dogar HaSsam','2017-07-08T22:33:38+0000',0),(11,'2017-07-09 13:45:00','165861103465048','165861103465048_1587071041344040','1587084371342707','1587093258008485','What are his timings?','1174112699360955','Ammar Ali Shah','2017-07-09T12:42:35+0000',0),(12,'2017-07-09 13:45:02','165861103465048','165861103465048_1587071041344040','1587084371342707','1587138711337273','They have a fbk page\nSalman paani puri','10159291391255347','Ammara Khan','2017-07-09T13:27:14+0000',0),(13,'2017-07-09 13:45:03','165861103465048','165861103465048_1587071041344040','1587084371342707','1587139571337187','Best pani puri in town although original was Tariq road pani puri Aunty but it tastes the same','10159291391255347','Ammara Khan','2017-07-09T13:28:11+0000',0),(14,'2017-07-09 13:45:09','165861103465048','165861103465048_1587071041344040','1587104671340677','1587105161340628','Too far away - DHA & SMCHS area preferred.','1174112699360955','Ammar Ali Shah','2017-07-09T12:50:25+0000',0),(15,'2017-07-09 13:45:10','165861103465048','165861103465048_1587071041344040','1587104671340677','1587153761335768','Then try red apple','1536015666437973','Abrar Hameed','2017-07-09T13:44:15+0000',0),(16,'2017-07-09 13:45:11','165861103465048','165861103465048_1587071041344040','1587104671340677','1587154378002373','Then try Flamingo, Boat Basin','1381987411883513','Shahzaib Abdullah','2017-07-09T13:44:54+0000',0),(17,'2017-07-09 13:45:22','165861103465048','165861103465048_1586341398083671','1586451358072675','1586457254738752','Hahaha whaaaat :O \nAb aesa bhi na kaho','1422690317817598','Areeba Viqar','2017-07-08T22:38:21+0000',0),(18,'2017-07-09 13:45:37','165861103465048','165861103465048_1586983448019466','1586988668018944','1586995151351629','?','10155209162900067','Marvi Ghanghro','2017-07-09T10:45:14+0000',0),(19,'2017-07-09 13:45:39','165861103465048','165861103465048_1586983448019466','1586988668018944','1586995451351599','Marvi Ghanghro messaged u','10158981903975182','Nida Ansar','2017-07-09T10:45:36+0000',0); +/*!40000 ALTER TABLE `replys` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `status` +-- + +DROP TABLE IF EXISTS `status`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `status` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `pageid` varchar(50) NOT NULL, + `next` varchar(1000) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `pageid` (`pageid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `status` +-- + +LOCK TABLES `status` WRITE; +/*!40000 ALTER TABLE `status` DISABLE KEYS */; +/*!40000 ALTER TABLE `status` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2017-07-09 22:54:36 diff --git a/README.md b/README.md index 5a338bf..2701851 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,18 @@ -# FacebookScraper +FBScraper +This code was originally created by Ibraheem Halloum name as (FacebookScraper) you can get original here: https://github.com/ihalloum/FacebookScraper.git + +I have updated some parts of this script (Shares Count,Reactions and Comments Count) + +This script scrapes posts and comments from facebook pages its with their details in mysql databases . +Requirements + +This script test under this Requirements + + Ubuntu OS. + Python [ installed already with ubuntu ] . + MySQL Server . install it by this command $ apt-get install mysql-server + Install MYSQLDB Python package $pip install MYSQLDB + This script scrapes posts and comments from facebook pages,groups and store its with their details in mysql databases . # Requirements diff --git a/config.py b/config.py index 55184f8..2de048e 100644 --- a/config.py +++ b/config.py @@ -12,7 +12,7 @@ # Database UserName username='root' # Database Password -password='' +password='lbr123' # Database Name DBName='fb_data' @@ -21,7 +21,7 @@ #list_pages = ["95969849939","95495949393"] list_pages = ["63811549237"] #Posts Details want to collect -posts_fields = "message,likes.limit(1).summary(true),from,created_time" +posts_fields = "message,likes.limit(1).summary(true),from,created_time,full_picture" # Number of posts you want to collect from signal page , min=25 fb_post_max = 3 # Enable Scrape Page @@ -29,20 +29,20 @@ #---------------------------------- Groups Var -------------------------------------- # Add the Groups ID #list_groups = ["9509465696t5534","56777754433"] -list_groups = ["1474176602870235"] +list_groups = ["165861103465048"] #Feeds Details want to collect -feeds_fields = "message,likes.limit(1).summary(true),from,created_time" +feeds_fields = "message,likes.limit(1).summary(true),from,created_time,full_picture" # Number of feeds you want to collect from signal group . min=25 -fb_feed_max = 3 +fb_feed_max = 1 # Enable Scrape Group scrape_group = 1 #---------------------------------- Pages & Groups Var ------------------------------ #Comments Details want to collect comments_fields = "message,likes.limit(1).summary(true),from,created_time" # tha max number of comments you want to collect from signal post -fb_comment_max = 3 +fb_comment_max = 0 # tha max number of Reply you want to collect from signal comment -fb_reply_max = 3 +fb_reply_max = 0 # tha max number of like you want to collect from signal post,comment,reply fb_like_max = 3 # Enable Scrape Comment diff --git a/group_functions.py b/group_functions.py index 18b121f..774017b 100644 --- a/group_functions.py +++ b/group_functions.py @@ -147,6 +147,7 @@ def get_fb_group_feeds( data_url ,group_id): likes = data["likes"] summary_likes = likes["summary"] total_likes= summary_likes["total_count"] + getImages(feed_id,group_id) add_query=("INSERT INTO Posts " "(pageid, postid,message,fromid,fromname,createdtime,total_likes) " "VALUES (%s,%s,%s,%s,%s,%s,%s)") @@ -234,3 +235,35 @@ def scan_fb_groups(scrape_comments,scrape_replys,scrape_likes): print "Total Scaned Groups Comments = " + str(fb_total_comment_counter) print "Total Scaned Groups Replys = " + str(fb_total_reply_counter) print "Total Scaned Groups Likes = " + str(fb_total_like_counter) + + + +def getImages(post_id,source_id): + current_page = "https://graph.facebook.com/v2.9/"+post_id+"?fields=attachments&access_token="+accesstoken + #print current_page + web_response = urllib2.urlopen(current_page) + readable_page = web_response.read() + json_fbpage = json.loads(readable_page) + try: + for i in json_fbpage["attachments"]["data"]: + try: + for k in i["subattachments"]["data"]: + src = k['media']['image']['src'] + width = k['media']['image']['width'] + height = k['media']['image']['height'] + #print str(width)+"----"+str(height) + add_query=("insert into images (source_id,post_id,src,width,height) values (%s,%s,%s,%s,%s)") + add_data = (source_id,post_id,src,width,height) + insert_row(add_query,add_data) + except KeyError: + #print "2nd method apply" + src = i['media']['image']['src'] + width = i['media']['image']['width'] + height = i['media']['image']['height'] + add_query=("insert into images (source_id,post_id,src,width,height) values (%s,%s,%s,%s,%s)") + add_data = (source_id,post_id,src,width,height) + insert_row(add_query,add_data) + #print str(width)+"----"+str(height) + except KeyError: + print "attachments" +