473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

sending commands in body of HTTP with urllib2

Hi,
Im trying to implement the logic from
http://www.hypothetic.org/docs/msn/g...onnections.php to a
simple python code using urllib2 and some parts of urllib. Im behind a
http proxy that requires authentication that is why Im using urllib2. Im
asking for help on how to send commands in a body of a HTTP before
requesting for response. What am I doing wrong? I only get the response
from the server but my commands never seem to be acknowledged or
properly handled. Below is my code:

import urllib2
import base64
import urllib

USER='user'
PASS='pass'

proxy_info = {'host' : "proxy.com.au",'port' : 8080}

# build a new opener that uses a proxy requiring authorization
proxy_support = urllib2.ProxyHandler({"http" : \
"http://%(host)s:%(port)d" % proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

user_pass = base64.encodestring('%s:%s' %
(urllib.unquote(USER),urllib.unquote(PASS)))
authheader = "Basic %s" % user_pass

opener.addheaders = [('Accept-Language','en-us'),
('Accept-Encoding','gzip, deflate'),
('Host','gateway.messenger.hotmail.com'),
('Proxy-Connection','Keep-Alive'),
('Connection','Keep-Alive'),
('Pragma','no-cache'),
('Content-Type','application/x-msn-messenger'),
('User-agent','MSMSGS'),
('Accept','*/*'),
('Proxy-authorization',authheader)]

# install it
urllib2.install_opener(opener)

# use it
url =
'http://gateway.messenger.hotmail.com/gateway/gateway.dll?Action=open&Server=NS&IP=messenger.hot mail.com'
values = 'VER 5 MSNP8 CVR0'

f = urllib2.urlopen(url,values)
print f.headers
print f.read()

Thanks for any help!
Jan 3 '08 #1
0 1250

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Wilson | last post by:
I am writing a script to check on my router's external IP address. My ISP refreshes my IP very often and I use dyndns for the hostname for my computer. My Netgear mr814 router has a webserver that...
2
by: OvErboRed | last post by:
Hi, I'm trying to determine whether a given URL exists. I'm new to Python but I think that urllib is the tool for the job. However, if I give it a non-existent file, it simply returns the 404 page....
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
4
by: Dekaritae | last post by:
I have a script that I've written in Perl that retrieves files generated from a template. It works decently enough, but I'd like to rewrite it in Python (Perl was just a detour; it was originally...
3
by: John Reese | last post by:
Hello there. I've run into some missing functionality with HTTP Digest authentication in the 2.3 library and I was wondering if I'm just missing something. Missing functionality the first:...
2
by: itay_k | last post by:
Hi, I want to send a cookie on some http request (with urllib2), so I created a Cookie but I cant associate it with CookieJar object. for example: import Cookie import cookielib, urllib2
2
by: jabdulius | last post by:
Hi all, I'm trying to send a page using Perl via the WCTP protocol. For some reason, I cannot connect to the host "wctp.att.net/WCTP" (or any host for that matter). I figure it must be some...
0
by: Jonas Galvez | last post by:
Try: import re import urllib2 url = 'http://www.google.com/search?num=20&hl=en&q=ipod&btnG=Search' user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = {'User-Agent' :...
2
by: silk.odyssey | last post by:
I am getting the following error trying to download an html page using urllib2. urllib2.HTTPError: HTTP Error 204: NoContent The url is of this type: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.