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

Python as a HTTP Client

I am writing a program that has to do some lightweight HTTP
communication with a webserver on the internet. I haven't checked, but
I'm sure I could do something lowlevel like opening a socket myself and
then send/receive everything myself on this (how do I do that?), but
I'd bet that Python have some module which is more high level.
Something that would just let me connect using an URL, send a few GETs,
and receive the answer as a string/file etc.

Does this exist, and where can I read about it?

/David

Nov 10 '05 #1
3 2103
If you haven't discovered www.python.org yet I suggest going there :P.
You will find there the documentation you need under the conspicuous
name library reference. Specifically the modules you'd probably most
be interested in are urllib/urllib2/httplib depending on what you
need. Their may be other external modules which fit your task even
better, try doing a search through the Python Package Index..
On 10 Nov 2005 05:02:32 -0800, pi************@gmail.com
<pi************@gmail.com> wrote:
I am writing a program that has to do some lightweight HTTP
communication with a webserver on the internet. I haven't checked, but
I'm sure I could do something lowlevel like opening a socket myself and
then send/receive everything myself on this (how do I do that?), but
I'd bet that Python have some module which is more high level.
Something that would just let me connect using an URL, send a few GETs,
and receive the answer as a string/file etc.

Does this exist, and where can I read about it?

/David

--
http://mail.python.org/mailman/listinfo/python-list

--
James Tanis
jt****@pycoder.org
http://pycoder.org
Nov 10 '05 #2
James Tanis wrote:
If you haven't discovered www.python.org yet I suggest going there :P.
You will find there the documentation you need under the conspicuous
name library reference. Specifically the modules you'd probably most
be interested in are urllib/urllib2/httplib depending on what you
need. Their may be other external modules which fit your task even
better, try doing a search through the Python Package Index..


To both you and Frederik:

I do know about www.python.org. I do an extensive amount of googling in
general and searching at python.org before I ask questions such as this.
I did stumble upon urllib, urllib2 and httplib in the documentation, but
let me assure you, as a newbie, that finding this documentation doesn't
make one go "ah, this is what I was looking for". Specifically, I can't
see from reference documentation whether something even smarter or more
highlevel exists. Fuzzyman's link did the trick. It also helped me
(after reading his articles) to understand the reference documentation
better.

/David
Nov 10 '05 #3
David Rasmussen wrote:
I do know about www.python.org. I do an extensive amount of googling in
general and searching at python.org before I ask questions such as this.
I did stumble upon urllib, urllib2 and httplib in the documentation, but
let me assure you, as a newbie, that finding this documentation doesn't
make one go "ah, this is what I was looking for". Specifically, I can't see from reference documentation whether something
even smarter or more highlevel exists.


hmm. so if that was your question, why did you write:

I am writing a program that has to do some lightweight HTTP
communication with a webserver on the internet. I haven't checked, but
I'm sure I could do something lowlevel like opening a socket myself and
then send/receive everything myself on this (how do I do that?), but
I'd bet that Python have some module which is more high level.
Something that would just let me connect using an URL, send a few GETs,
and receive the answer as a string/file etc.

? ("I haven't checked ... but I'd bet" doesn't really sound like "I've checked
the docs and found a couple of modules that seem to do this, but I wonder
if there is something better out there")

....especially if you had already seen the tutorial's

Internet Protocols

There are a number of modules for accessing the internet and processing
internet protocols. Two of the simplest are urllib2 for retrieving data
from urls /.../

(followed by a brief example that shows how to read from an URL)

or the reference guide's

urllib -- Open arbitrary resources by URL

This module provides a high-level interface for fetching data across the
World Wide Web. In particular, the urlopen() function is similar to the built-
in function open(), but accepts Universal Resource Locators (URLs) instead
of filenames.

or

urllib2 -- extensible library for opening URLs

The urllib2 module defines functions and classes which help in opening URLs
(mostly HTTP) in a complex world -- basic and digest authentication, re-
directions, cookies and more.

which all seem to match "something that would just let me connect
using an URL" pretty well.

</F>

Nov 10 '05 #4

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

Similar topics

0
by: Irmen de Jong | last post by:
QOTW: "Giving full access rights to a secretary or new programmer ought to insure an occasional random file deletion." -- Raymond Hettinger "I always use join, but that's probably because that...
0
by: Irmen de Jong | last post by:
QOTW: "Confronting the Martellibot is like flirting with an encyclopedia, I'd rather not do it myself, but I respect those who do, because it produces knowledge." -- Anton...
0
by: Raymond Hettinger | last post by:
QOTW: "Python seems to encourage and reward incremental effort, and it leads one to explore extensions and improvements to programs because the language makes it relatively easy to see how to do...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
29
by: Frank Millman | last post by:
Hi all I am writing a multi-user accounting/business system. Data is stored in a database (PostgreSQL on Linux, SQL Server on Windows). I have written a Python program to run on the client,...
0
by: Rafal Zawadzki | last post by:
Hi. I tried earlier to write python zsi mail list, but nobody answered. I am using ZSI 1.7/2.0rc1 with TTPro Soap SDK. The wsdl file can be found here: http://demo.seapine.com/ttsoapcgi.wsdl ...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
28
by: H J van Rooyen | last post by:
Hi, I want to write a small system that is transaction based. I want to split the GUI front end data entry away from the file handling and record keeping. Now it seems almost trivially easy...
37
by: Michael Palmer | last post by:
As anyone knows, the state of Python GUI programming is a little fractured at this time, with many toolkits, wrappers and meta-wrappers dead and alive, with or without documentation. I've come...
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: 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?
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
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
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...
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...
0
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,...

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.