Scraping comments of a facebook post

This is a basic example of scrapping comments of a facebook post using python and facebook sdk

I hope you have python and know how to install a package.

Lets install facebook using pip

pip install facebook-sdk

We are proceeding directly in python

Before that we need an access token to connect to facebook.

Get the access token from here:

Access token is the pretty long string inside the textbox on the side where it is written “Access Token”

Now lets get those comments

graph = facebook.GraphAPI(access_token=’your pretty long string which you have copied now’)

post = graph.get_object(id = ‘post id’)

You can get the post id, by opening an url of a post in facebook

If url to a post is then, “10153947250687139” is the post id

print post

This will print bunch of details about the post including first 10 likes and first 10 comments

If you just need to see the comments

print post[‘comments’]

This will show just the comments.

If you need the remaning comments/likes, you will need to iterate the “cursors”, which doesn’t cover in basics. So just stopping here.

If you need further clarifications, please comment. If you wish to have Part 2 of this post, comment.

Njoy smile

Library not loaded: libcrypto.1.0.0.dylib issue in mac

You might have come across this error while dealing with the openssl module.

Inorder to solve this issue follow the following steps

Step 1: Install openssl using brew

brew install openssl

Step 2: Copy copy libssl.1.0.0.dylib and libcrypto.1.0.0.dylib

cd /usr/local/Cellar/openssl/1.0.1f/lib

sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/lib/

Note the bold folder name. There will be change in that depending on your openssl version

Step 3: Remove the existing links

sudo rm libssl.dylib libcrypto.dylib

sudo ln -s libssl.1.0.0.dylib libssl.dylib

sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib

That’s it. Now try installing what you have been trying to install.

I hope this helps. If you need any further clarification, do comment.

Enjoy smile

Install OpenCV for python in OSX Mavericks 10.9

#Assuming that you have installed Xcode, Command Line Tools, CMake, and Python

#Install ScipySuperpack

~$ curl >

~$ sh

#Download OpenCV 2.4.2

#Extract OpenCV-2.4.2.tar.bz2

#Open Terminal at the extracted directory

#At OpenCV-2.4.2 directory:

~$ echo "#define GTEST_USE_OWN_TR1_TUPLE 1" | cat > temp1

~$ cat modules/ts/include/opencv2/ts/ts_gtest.h > temp2

~$ cat temp1 temp2 > modules/ts/include/opencv2/ts/ts_gtest.h

~$ mkdir build

~$ cd build

~$ cmake .. -Wno-dev

~$ make -j8 && sudo make install

#Update your bash_profile:

~$ echo "export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH" >> ~/.bash_profile

#Close and open the Terminal

#Open python console and try to import cv2 to test if everything works

~$ python import cv2

Installing pygame in OSX Mavericks

pip install numpy
brew install sdl sdl_ttf sdl_image sdl_mixer

Download the pygame source. It’s one of the top links. Extract it somewhere and go to that directory in a terminal.

Run python

Open "Setup" file that will be found after running the above command .
Change the lines starting SDL, FONT, IMAGE, and MIXER to read:

SDL = -I/usr/local/include/SDL -L/usr/local/lib -lSDL
FONT = -lSDL_ttf
IMAGE = -lSDL_image
MIXER = -lSDL_mixer

open and edit scale_mmx64.c from /src folder .

Look for all occurrences of movsxl and replace it with movslq.
You should find two occurrences.

Run python install.