Hi all,
It seems the server I was trying to reach did'nt like the 'default http proxy of Boxee'.
I'm not 100% sure about that but still, here is the code I used to solve the problem :
Code:
from BeautifulSoup import BeautifulSoup, SoupStrainer
import urllib2
BASE_URL = "http://some-url.com"
# "Bypass" BOXEE proxy (if not we'll have error 61, 'connection refused')
proxy_support = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
# Fake user-agent to make sure the server let us in
user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
headers = { "User-Agent" : user_agent }
# Build a request
request = urllib2.Request( BASE_URL, {}, headers )
# Try to reach the server
try:
response = urllib2.urlopen(request)
except IOError, e:
if hasattr(e, 'reason'):
print 'We failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'):
print 'The server couldn\'t fulfill the request.'
print 'Error code: ', e.code
return None
# Everything went well
print response.read()
response.close
Voilą !
http://www.voidspace.org.uk/python/a....shtml#proxies
Bookmarks