newbie problem with urllib.urlopen

Roman Suzi rnd at onego.ru
Tue May 22 11:58:16 EDT 2001


On Tue, 22 May 2001, Wendelin Auer wrote:

>Hello,
>I'm no python programmer, but I have to fix a python problem in a search
>engine.
>I want to fetch two urls and write the content in the header and footer part
>of a html-file.
>It nearly works, but theres one problem left. Don't worry about the strange
>output mode, this is a part of one of many html-templates with scripted
>python:
>
>..........
><!--$
>import urllib
>f = urllib.urlopen("http://www.url.de/test/footer.txt")
>data = f.read()
>f.close()
>-->
>&$data;
>.............


Probably the server (?) which handles insertion of embedded
code makes < from < and so on?
(Because urlopen returns EXACTLY what web-server gives.

Why not just use SSI if it's a web-server?


>
>
>I hope this is not ridicolous ;-)
>My Problem: This returns something like:
>
>    <td nowrap bgcolor="#e5edf0"><img
>src="images/pix.gif" width="1"
>height="1"></td>
>  </tr>
></table>
></body>
></html>
>
>This is what was fetched:
><td nowrap bgcolor="#e5edf0">
><img src="images/pix.gif" width="1" height="1">
></td>
></tr>
></table>
></body>
></html>
>
>All linebreaks are gone, too.
>What I need is a way to decode, or even better, to get exactly the content
>of the fetched url into the data-variable.
>Please do not only explain, an example would be nice, i'm an absolute
>beginner.
>Thanks in advance,
>Wendelin Auer
>
>
>
>

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Tuesday, May 22, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Never trust a computer you can't lift. - Stan Masor" _/





More information about the Python-list mailing list