Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fb data extraction error
#1
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()
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is the error of not being able to pull data in this code? i didn't see an error? TestPerson 2 1,183 Sep-30-2022, 02:36 PM
Last Post: DeaD_EyE
  Python Scrapy Date Extraction Issue tr8585 1 3,236 Aug-05-2020, 04:32 AM
Last Post: tr8585
  Article Extraction - Wordpress svzekio 7 5,206 Jul-10-2020, 10:18 PM
Last Post: steve_shambles
  Follow Up: Web Calendar based Extraction AgileAVS 0 1,469 Feb-23-2020, 05:39 AM
Last Post: AgileAVS
  Email extraction from websites stefanoste78 14 11,978 Aug-18-2017, 09:44 PM
Last Post: stefanoste78
  Requisites for live data extraction and display Denniz 1 3,002 May-03-2017, 08:54 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020