Hello All,
I am using email to create a multipart message that I need to post to
a url.
I have been doing it semi-manually with httplib:
h = httplib.HTTP(se lf.host)
h.putrequest("P OST", self.url)
h.putheader("Ho st", self.host)
# Lot of other headers here...
# Here is where it gets ugly
h.putheader("Co ntent-Type", 'multipart/mixed;
boundary="===== ==========08140 72620=="'
# Where I had to figure out what that was from my Message object I
created earlier.
# Now do ugly stuff to strip off the first 2 lines from my
msg.as_string()
# (omited due to modesty... It's too ugly)
h.putheader("Co ntent-length", str(len(strippe d_msg)))
h.endheaders()
h.send(stripped _msg)
Can someone sugest a cleaner way of doing this sort of thing using
urllib2? The problem is getting the Content-Type header from my email
object to be used by urllib2 as an http header.
Thanks,
Joseph 0 1390 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John F Dutcher |
last post by:
Can anyone comment on why the code shown in the Python error is in
some way incorrect...or is there a problem with Python on my hoster's
site ??
The highlites don't seem to show here...but line #80 and line # 38 are
the first line offenders.
--> --> -->
|
by: jacob c. |
last post by:
When I request a URL using urllib2, it appears that urllib2 always
makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use
the "If-None-Match"/"ETag" HTTP headers to conserve bandwidth, but if
I'm not mistaken, these are HTTP 1.1 headers, so I can't reasonably
expect a web server to respond correctly to my requests. (In my
limited testing, it looks like some servers respond correctly with an
HTTP 304 status, while some...
|
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',
|
by: Robert |
last post by:
using a proxy and https/SSL together I get the following SSL error :
File "dscore.pyo", line 2257, in UrlOpenEx
File "ClientCookie\_urllib2_support.pyo", line 572, in open
File "ClientCookie\_urllib2_support.pyo", line 472, in http_response
File "ClientCookie\_urllib2_support.pyo", line 589, in error
File "urllib2.pyo", line 304, in _call_chain
File "ClientCookie\_urllib2_support.pyo", line 181, in http_error_302
File...
|
by: Ali.Sabil |
last post by:
hello all,
I just maybe hit a bug in both urllib and urllib2, actually urllib
doesn't support proxy authentication, and if you setup the http_proxy
env var to http_proxy=http://user:passwd@host:port/ and
https_proxy=$http_proxy i get a traceback :
Traceback (most recent call last):
File "test_urllib.py", line 2, in ?
urllib.urlopen("https://sf.net/")
| |
by: Nirnimesh |
last post by:
I'm using urllib2 module to fetch a URL from a server which understands
HTTP/1.1 only (no HTTP/1.0).
urllib2.urlopen() results in "urllib2.HTTPError: HTTP Error 505: HTTP
Version not supported".
How do I force urllib2 to use HTTP v1.1?
Regards,
Nirnimesh
|
by: m.banaouas |
last post by:
Hi all,
I started to use urllib2 library and HTTPBasicAuthHandler class in order
to authenticate with a http server (Zope in this case).
I don't know why but it doesn't work, while authenticating with direct
headers manipulation works fine!
WinXP Sp2
Python 2.4.4
Thanks in advance for your help/comments
|
by: Joshua Kugler |
last post by:
Standard disclaimer: read, googled, read some more. If you have a link,
please free free to point me there.
I'm using HTTPlib to construct some functional tests for a web app we're
writing. We're not using urllib2 because we need support for PUT and
DELETE methods, which urllib2 does not do.
We also need client-side cookie handling. So, I start reading about
cookielib and run across a problem. It's cookie handling is tied quite...
|
by: konstantin |
last post by:
Hi,
I wonder if there is a safe way to download page with urllib2. I've
constructed following method to catch all possible exceptions.
def retrieve(url):
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = {'User-Agent':user_agent}
request = urllib2.Request(url, headers=headers)
try:
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |