3 Replies - 1533 Views - Last Post: 19 May 2011 - 09:11 AM Rate Topic: -----

#1 VulcanDesign  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 98
  • Joined: 06-December 09

Error using Python's urllib

Posted 19 May 2011 - 06:56 AM

Hi all,

I'm trying to use Python's urllib to get a Facebook profile page. I get the following error:
IOError: [Errno socket error] [Errno 10035] A non-blocking socket operation could not be completed immediately


Here's my code:
import urllib
member_profile_text = urllib.urlopen('http://www.facebook.com/profile.php?id=1073109649').read()


I thought it might be a timeout issue, and tried the following code to no avail:
import socket
socket.setdefaulttimeout(60)
member_profile_text = urllib.urlopen('http://www.facebook.com/profile.php?id=1073109649').read()


I need to get this working soon, so any help would be extremely appreciated.

Thanks so much!
Benjamin

Is This A Good Question/Topic? 0
  • +

Replies To: Error using Python's urllib

#2 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 797
  • Joined: 08-June 10

Re: Error using Python's urllib

Posted 19 May 2011 - 07:04 AM

It may behoove you to try urllib2.urlopen, as it allows you to specify a timeout.

import urllib2
member_profile_text = urllib2.urlopen('http://www.facebook.com/profile.php?id=1073109649', timeout=3000).read()


This post has been edited by Motoma: 19 May 2011 - 07:06 AM

Was This Post Helpful? 2
  • +
  • -

#3 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Error using Python's urllib

Posted 19 May 2011 - 07:25 AM

Also, facebook's API is pretty awesome, you should try it!

This post has been edited by atraub: 19 May 2011 - 07:27 AM

Was This Post Helpful? 1
  • +
  • -

#4 VulcanDesign  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 98
  • Joined: 06-December 09

Re: Error using Python's urllib

Posted 19 May 2011 - 09:11 AM

Thanks so much, both of you. It works perfectly now! I appreciate the help,
Benjamin
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1