Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 27th, 2012, 06:29 PM
MynE MynE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 35 MynE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 59 sec
Reputation Power: 1
About Python for facebook API [parsing messagefile]

Hello,
I'm newbie in Python and I'm now learning about Facebook API in Python. I'm trying to parse the message data from facebook which I can do query from
https://graph.facebook.com/search?q=Query&type=post&access_token=

Frist, I parse the data from url and I load url into json format, then I retreive data as ['data']
but the problem is when I fetch data from query ['message'], it works but it got crashed because the next line has not "message" in that query. My question is I want to fetch lots of data but I don't want my application to get stopped when it found that the next line has no "message" on that query, what should I do?

Here's my code:

Code:
url ='https://graph.facebook.com/search?q=Query&type=post&access_token=&limit=50'
response = urllib.urlopen(url).read()
data = json.loads(response)
results = data['data']

for i in range(50):
      print results[i]['message']+':'+'\n'

Assume that when the data goes to i=9, and that line has no query name 'message', my application will stop at that line and not continue to run until it finished. If you know something about my problem, please help me.

I'm looking forward to see your answer,
Thank you so much

Reply With Quote
  #2  
Old December 4th, 2012, 09:44 PM
MynE MynE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 35 MynE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 59 sec
Reputation Power: 1
Oh gosh, nobody can answer my question at all, I've tried so many ways but it still can not pass when that line has no ['message']
I'm stuck can somebody at least suggest about how to skip the line or how to continue running by ignore an error value please..

Reply With Quote
  #3  
Old December 5th, 2012, 09:52 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,361 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 11 sec
Reputation Power: 383
Run the process in a separate thread and kill it when a timer expires.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > About Python for facebook API [parsing messagefile]

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap