473,386 Members | 1,832 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,386 software developers and data experts.

% in POST when using URLLIB2.URLOPEN with PROXY

Hey.

Im trying to post some variables to an URL, but I get an error saying that
my XML is parsed incorrectly. I know that it is not. At closer inspection
I found out that some module in Python must be screwing up my request when
I try to send it.

Previously the code worked fine, but the problem occured when I included
the proxy/authentication code, so that must be what is messing around with
my request.

I substituted the original URL with a Zope script to post variable and
send them back to see what I get, testing it with and without the Proxy
code.

Here is the code:
#==========================

import urllib2

infoRequest = "<GETCLIENTSERVICES/>"
# VARIABLES TO SEND... it is the ArcXMLRequest that's going haywire!
params = urllib.urlencode({'ArcXMLRequest': infoRequest,
'JavaScriptFunction':'processXML',
'RedirectURL':'',
'BgColor':'#000000',
'FormCharset':'ISO-8859-1'})

proxy_info = {'port': 8080,
'host': '172.16.13.9',
'user': 'username',
'pass': 'password'}

proxy_support = urllib2.ProxyHandler({"http" :
"http://%(user)s:%(pass)s@%(host)s:%(port)s" %
proxy_info})

opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

urllib2.install_opener(opener)

req = urllib2.Request('http://serverX/debugScript', params) # Zope
server, or ARCIMS Server

u = urllib2.urlopen(req)
print u.read()

#===========================

http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERVICES/>"
but instead I get :
"<GETCLIENTSERVICES/%"

When I send "<GETCLIENTSERVICES/>\n\n" instead of "<GETCLIENTSERVICES/>",
I get back "<GETCLIENTSERVICES/>\n%" as a result.

If I'm not clear enough about the problem, please shout. Help will be
appreciated!!

Thanks

Herman

Jul 18 '05 #1
1 2921
"Herman Geldenhuys" <he**************@fusemail.com> writes:
[...]
http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERVICES/>"
but instead I get :
"<GETCLIENTSERVICES/%"

When I send "<GETCLIENTSERVICES/>\n\n" instead of "<GETCLIENTSERVICES/>",
I get back "<GETCLIENTSERVICES/>\n%" as a result.

If I'm not clear enough about the problem, please shout. Help will be
appreciated!!

[...]

I wonder why, given your very clear explanation of the problem, you
haven't gone the extra inch to figure out why the code (urllib2+your
code) is posting incorrect data.

Somebody here might well guess the right answer to the problem, but
why not simply find out for yourself -- you're obviously quite capable
of doing so! Get those print statements in there!

Once you've done so, please help save the world and let us know what
the problem was.
John
Jul 18 '05 #2

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

Similar topics

4
by: O. Koch | last post by:
Until now, i know that ftplib doesn't support proxies and that i have to use urllib2. But i don't know how to use the urllib2 correct. I found some examples, but i don't understand them. Is...
2
by: Andre Bocchini | last post by:
I'm having some trouble using proxy authentication. I can't figure out how to authenticate with a Squid proxy. I know for a fact the proxy is using Basic instead of Digest for the authentication....
4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
0
by: Lee, Dustin | last post by:
I'm using python2.2.2 on redhat linux 7.3 Here's a snippet of what I'm trying to run: # set up proxy import urllib2 proxy_support =...
5
by: Max M | last post by:
I am using ClientCookie for login on to servers and browsing them as authenticated users. I kept getting "HTTP Error 400: Bad Request" errors when submitting my forms. So I boiled it down to a...
0
by: Matt | last post by:
I'm trying to get the HTML data off of a webpage. Let's say for the sake of argument it's the python homepage. I've googled around and found some examples that people said worked. Here's what...
0
by: Pieter Edelman | last post by:
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's...
1
by: est | last post by:
A simple py script import urllib2 req=urllib2.Request("http://www.google.com") req.set_proxy("127.0.0.1:1","http") print urllib2.urlopen(req).read()
1
by: Magnus.Moraberg | last post by:
Hi, I have the following code - import urllib2 from BeautifulSoup import BeautifulSoup proxy_support = urllib2.ProxyHandler({"http":"http:// 999.999.999.999:8080"}) opener =...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.