All Projects → victorloux → fb-scraper

victorloux / fb-scraper

Licence: Unlicense License
Scrape a Facebook profile and turn it into a JSON file

Programming Languages

coffeescript
4710 projects

Projects that are alternatives of or similar to fb-scraper

Spam Bot 3000
Social media research and promotion, semi-autonomous CLI bot
Stars: ✭ 79 (+338.89%)
Mutual labels:  scraper, facebook, research
Hybridauth
Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.
Stars: ✭ 3,223 (+17805.56%)
Mutual labels:  facebook, social-networks
Ai Residency List
List of AI Residency & Research programs, Ph.D Fellowships, Research Internships
Stars: ✭ 69 (+283.33%)
Mutual labels:  facebook, research
Fbcrawl
A Facebook crawler
Stars: ✭ 536 (+2877.78%)
Mutual labels:  scraper, facebook
Skraper
Kotlin/Java library and cli tool for scraping posts and media from various sources with neither authorization nor full page rendering (Facebook, Instagram, Twitter, Youtube, Tiktok, Telegram, Twitch, Reddit, 9GAG, Pinterest, Flickr, Tumblr, IFunny, VK, Pikabu)
Stars: ✭ 72 (+300%)
Mutual labels:  scraper, facebook
SocialInfo4J
fetch data from Facebook, Instagram and LinkedIn
Stars: ✭ 44 (+144.44%)
Mutual labels:  scraper, facebook
Socialmanagertools Gui
🤖 👻 Desktop application for Instagram Bot, Twitter Bot and Facebook Bot
Stars: ✭ 293 (+1527.78%)
Mutual labels:  scraper, facebook
sharon
A lightweight and modular social sharing library
Stars: ✭ 16 (-11.11%)
Mutual labels:  facebook, social-networks
Serpscrap
SEO python scraper to extract data from major searchengine result pages. Extract data like url, title, snippet, richsnippet and the type from searchresults for given keywords. Detect Ads or make automated screenshots. You can also fetch text content of urls provided in searchresults or by your own. It's usefull for SEO and business related research tasks.
Stars: ✭ 153 (+750%)
Mutual labels:  scraper, research
scrapy facebooker
Collection of scrapy spiders which can scrape posts, images, and so on from public Facebook Pages.
Stars: ✭ 22 (+22.22%)
Mutual labels:  scraper, facebook
facebook-discussion-tk
A collection of tools to (semi-)automatically collect and analyze data from online discussions on Facebook groups and pages.
Stars: ✭ 33 (+83.33%)
Mutual labels:  scraper, facebook
universal-routed-flux-demo
The code in this repo is intended for people who want to get started building universal flux applications, with modern and exciting technologies such as Reactjs, React Router and es6.
Stars: ✭ 31 (+72.22%)
Mutual labels:  facebook
Data-mining-python-script
It contain various script on web crawling/ data mining of social web(RSS,facebook,twitter,Linkedin)
Stars: ✭ 24 (+33.33%)
Mutual labels:  facebook
aboutmeinfo-telegram-bot
ℹ️ About Me Info Bot: Share your social media and links on Telegram
Stars: ✭ 20 (+11.11%)
Mutual labels:  facebook
Ananas
An easy image editor integration for your Android apps.
Stars: ✭ 186 (+933.33%)
Mutual labels:  facebook
ai-distillery
Automatically modelling and distilling knowledge within AI. In other words, summarising the AI research firehose.
Stars: ✭ 20 (+11.11%)
Mutual labels:  research
kaa.si-cli
Stream anime from kaa.si and sync with anilist
Stars: ✭ 12 (-33.33%)
Mutual labels:  scraper
Instagram-Scraper-2021
Scrape Instagram content and stories anonymously, using a new technique based on the har file (No Token + No public API).
Stars: ✭ 57 (+216.67%)
Mutual labels:  scraper
fiction-dl
A content downloader, capable of retrieving works of (fan)fiction from the web and saving them in a few common file formats.
Stars: ✭ 22 (+22.22%)
Mutual labels:  scraper
SearchScraperAPI
Aiohttp web server API, which scrapes Google and returns scrape results as response. Supports proxies, multiple geos and number of results.
Stars: ✭ 31 (+72.22%)
Mutual labels:  scraper

fb-scraper

fb-scraper is a script to scrape all of someone else’s statuses on Facebook. This cannot be done via the API, so it uses PhantomJS and CasperJS to run a headless browser, go to someone's profile page, and keeps scrolling down infinitely until the profile was created; then it gets all the text statuses and converts them to a JSON file looking like this:

[
	{
		"content":"Text update",
		"permalink":"/user/posts/1234567890",
		"time":"18 February at 15:08",
		"timestamp":1424272112,
		"likes": 9,
		"shares": 0,
		"comments": 0,
		"isFriendPost":false
	},
	...
]

It only gets text statuses and posts received to the wall, but you could easily modify it to get other types of posts, and keep more metadata fields. There is also a script to batch insert this JSON into a MySQL database.

If you would like to archive your own profile then you're probably better off using Facebook’s Download My Information as this will be much more structured and complete than this.

Ethical considerations

Is this tool ethical? Depends how you use it. It’s certainly against Facebook's terms of service, and you should not archive someone's profile without their explicit, informed consent. Essentially you should only use this if you're doing research on social networks that specifically requires this data.

It is your responsibility to take appropriate steps to keep the resulting data safe, such as strong file encryption, in order to protect the participants’ privacy; and delete raw data when it's not needed anymore. Where possible, you should also anonymise the data early on, by renaming your files and removing the permalink field, but remember that the content of updates and metadata may still contain personally identifiable information. See “But the data is already public” (Zimmer, 2010) and “I Didn’t Sign Up for This!” (Hutton and Henderson, 2015) to learn more about the dangers of data leaks in SNS studies.

I assume no responsibility for improper or unethical use of this tool.

Setup

Installation

Requires node.js and npm.

  • Clone the repository: git clone https://github.com/victorloux/fb-scraper.git
  • Install PhantomJS, and make sure it is in your $PATH
  • From the fb-scraper folder, run npm install to install the dependencies

The scripts are written and annotated in CoffeeScript, but JS transpilations are provided for convenience (and because PhantomJS 2 does not directly read CoffeeScript anymore). If you would like to edit the scripts I recommend you install CoffeeScript instead of editing the JS files directly.

Authentication

Set your shell’s environment variables $fb_user and $fb_pass to the Facebook username/password you'd normally use to log in. The easiest and safer way to do it is to duplicate the file .env.example, rename it to .env, and then edit this file with your username/email and password. Once this is done you'll need to run source .env in your shell.

Usage

Get someone's statuses

casperjs --config=conf.json scrape.js USERNAME

Where USERNAME is either a profile ID, or the username that comes after the / in their URL. If username is omitted then it will steal Mark Zuckerberg’s profile by default. Take that, Zuck.

Modifying the parsing script

Once you have scraped a profile, and want to edit the code to change how a raw HTML status is parsed into JSON, you can add --parse-only which will use the cached version of the scraped profile (ending with .raw) to generate a new JSON file, instead of trying to re-download the whole thing every time which is quite long.

The code needs to be refactored to a cleaner state but should still be readable. Give me a shout if you really don't understand anything.

Also, remember to compile your CoffeeScript before running CasperJS, or you'll run the older JS file. A watch script is useful.

Push into a database

Setup a MySQL table with the following fields (adjust as needed if you created new fields):

CREATE TABLE `statuses` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `user` varchar(255) DEFAULT NULL,
  `content` text,
  `permalink` varchar(255) DEFAULT NULL,
  `timestamp` bigint(20) DEFAULT NULL,
  `likes` int(11) DEFAULT NULL,
  `shares` int(11) DEFAULT NULL,
  `comments` int(11) DEFAULT NULL,
  `is_friend_post` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
);

Edit save-to-db.coffee and .env with your database credentials. Then run:

coffee save-to-db.js USERNAME

To do

The script has some (many) bugs, and lacks tests, graceful error handling, configuration, and better sanitisation of the statuses to a usable format. It's all quite hard to do reliably because it's a headless browser, and unexpected changes in the page are harder to detect, but it will be fixed someday. In the meantime, PRs welcome if that project is particularly useful to you.

Also there's an awful “fix” somewhere which causes profiles with over 150 pages to not be downloaded in full. If it's a blocker for you adjust the code as needed, it's an arbitrary number because some profiles never show a Born event and so the script never stops. Until I find an actual fix.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].