473,799 Members | 2,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

% 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 = "<GETCLIENTSERV ICES/>"
# VARIABLES TO SEND... it is the ArcXMLRequest that's going haywire!
params = urllib.urlencod e({'ArcXMLReque st': infoRequest,
'JavaScriptFunc tion':'processX ML',
'RedirectURL':' ',
'BgColor':'#000 000',
'FormCharset':' ISO-8859-1'})

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

proxy_support = urllib2.ProxyHa ndler({"http" :
"http://%(user)s:%(pass )s@%(host)s:%(p ort)s" %
proxy_info})

opener = urllib2.build_o pener(proxy_sup port, urllib2.HTTPHan dler)

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 :
"<GETCLIENTSERV ICES/>"
but instead I get :
"<GETCLIENTSERV ICES/%"

When I send "<GETCLIENTSERV ICES/>\n\n" instead of "<GETCLIENTSERV ICES/>",
I get back "<GETCLIENTSERV ICES/>\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 2940
"Herman Geldenhuys" <he************ **@fusemail.com > writes:
[...]
http://serverX/debugScript only returns the ArcXMLRequest that was posted.
It should be :
"<GETCLIENTSERV ICES/>"
but instead I get :
"<GETCLIENTSERV ICES/%"

When I send "<GETCLIENTSERV ICES/>\n\n" instead of "<GETCLIENTSERV ICES/>",
I get back "<GETCLIENTSERV ICES/>\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
21119
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 there anyone who can help me?
2
34998
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. I can authenticate just fine using Mozilla. I've done some Google searches, but the closest piece of code I've is is for HTTPBasicAuthHandler: # set up authentication info authinfo = urllib2.HTTPBasicAuthHandler()...
4
4463
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 python 2.3 Here is an exemple of the piece of code I use: import urllib2 #Proxy handler proxy_handler = urllib2.ProxyHandler({"http" :
0
1436
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 = urllib2.ProxyHandler({"http":"http://webproxy.mycompany.com:3128"}) #proxy_support = urllib2.ProxyHandler() opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener)
5
1790
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 simple example. When I try to use ClientCookie.urlopen() on my private network with ip numbers like "http://localhost:8081/test_site/logged_in", it works fine. If I try to call the same site through the Internet, with a url like:
0
4978
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 I've cobbled together: #getHTML.py ############################################ import urllib import urllib2 proxy_info = {'user':'us3r',
0
3600
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 my cry for help. The server is an elog logbook server (http://midas.psi.ch/elog/). It is protected with a password and an empty username. I can login both using urllib and urllib2 (suppose the password is "foobar", the logbook is running on port...
1
4844
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
3375
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 = urllib2.build_opener(proxy_support)
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10482
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.