data from a web page

Maschio_77 maschio_77 at hotmail.com
Mon Oct 21 03:31:37 EDT 2002


Ok , I understand how to use htplib or urllib,now I'm just courios to know
if I can use socket too, I think something like this:

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(www.somesite.com, 80)
s.send("XXX")
data=s.recv(1024)
s.close()

wich XXX I've to send to receiv the html code from the web server?

thanks

"Gerhard Häring" <gerhard.haering at gmx.de> ha scritto nel messaggio
news:mailman.1035153205.27567.python-list at python.org...
> * Maschio_77 <maschio_77 at hotmail.com> [2002-10-20 22:00 +0000]:
> > "bromden" <bromden at gazeta.pl> wrote:
> > > what do you exactly mean?
> > > [...]
> > > - you just want to read a webpage? look here:
> > >    http://www.python.org/doc/current/lib/module-httplib.html
> > >
> > > The first: I want to read the web page content from my little
> > > program to take some data
>
> gerhard at gargamel:~$ python
> Python 2.2.2 (#1, Oct 18 2002, 03:24:30)
> [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import urllib
> >>> print urllib.urlopen("http://www.python.org/").read()
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <?xml-stylesheet href="./style.css" type="text/css"?>
> <html>
> [...]
>
> More in the docs about the urllib module.
>
> HTH,
>
> -- Gerhard
>





More information about the Python-list mailing list