Facebook Comment Crawling
First of all, you learn about split of a string. It is very useful for capturing the comments from social media. Split is use for breaking the sentence in to parts.
For Example:
>>> string = 'Hello, this is test String'
>>> splitup = string.split(',')
>>> print splitup
Result: ['Hello', ' this is test String']
If we use print splitup[0], Result will be Hello and if print splitup[1], then result will be this is test String.
here, we are using same concept for capturing comments from Facebook.
Program for Capturing data From Facebook Post.
import time
import urllib2
from urllib2 import urlopen
import datetime
website = 'https://www.facebook.com/micromaxinfo/photos/a.135353393141505.25202.120735417936636/960349747308528/?type=1&theater'
topSplit = 'body\":{\"text\":\"'
bSplit = '\",\"ranges\":'
sourceCode = urllib2.urlopen(website).read()
for i in range(1,50):
sourceCodeSplit = sourceCode.split(topSplit)[i].split(bSplit)[0]
print i
print sourceCodeSplit
This program ill print the 50 comments from this post Given in this program. If you want to capture comments from different post ,you just replace the Facebook post link.
First of all, you learn about split of a string. It is very useful for capturing the comments from social media. Split is use for breaking the sentence in to parts.
For Example:
>>> string = 'Hello, this is test String'
>>> splitup = string.split(',')
>>> print splitup
Result: ['Hello', ' this is test String']
If we use print splitup[0], Result will be Hello and if print splitup[1], then result will be this is test String.
here, we are using same concept for capturing comments from Facebook.
Program for Capturing data From Facebook Post.
import time
import urllib2
from urllib2 import urlopen
import datetime
website = 'https://www.facebook.com/micromaxinfo/photos/a.135353393141505.25202.120735417936636/960349747308528/?type=1&theater'
topSplit = 'body\":{\"text\":\"'
bSplit = '\",\"ranges\":'
sourceCode = urllib2.urlopen(website).read()
for i in range(1,50):
sourceCodeSplit = sourceCode.split(topSplit)[i].split(bSplit)[0]
print i
print sourceCodeSplit
This program ill print the 50 comments from this post Given in this program. If you want to capture comments from different post ,you just replace the Facebook post link.