Python Forum

Full Version: fb data extraction error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Everyone, i'm in learning phase and unable to understand my mistake in retrieving fb data.

kindly help me in identifying my mistake.

Much thanks in advance

Error : syntax error
indentation error for this line ( graph = facebook.GraphAPI(access_token))


# Program to mine data from your own facebook account
###  Facebook user account data extraction
from bs4 import BeautifulSoup
import urllib3
import requests
import json
import facebook

def main():
	access_token =  "{your token}"
    graph = facebook.GraphAPI(access_token)
    #fields = ['first_name', 'location{location}','email','link']
	profile = graph.get_object(id='me',fields='first_name,location,link,email')	
	#return desired fields
	print(json.dumps(profile, indent=4))

if __name__ == '__main__':
	main()
       
### Facebook page data mining

import json
import facebook

def main():
      access_token = "{your token}"
      graph = facebook.GraphAPI(access_token)
      page_name = raw_input("Enter a page name: ")
      
      # list of fields required
      fields = ['id','name','about','link','likes','band_members']
      
      fields = ','.join(fields)
      
      page = graph.get_object(page_name,fields=fields)
     
      print(json.dumps(page,indent(4))

if __name__ == '__main__':
    main()
Nothing appears wrong with the indentation. Did you post the full error traceback?

Since there are two main functions, I'm supposing this is in Jupyter Notebooks. Otherwise, the script should give you an error because of a non-unique names.