Article View: pl.comp.lang.python
Article #277Re: połączenia http - ściąganie plików
From: Marcin Wojtczuk
Date: Mon, 09 Dec 2002 19:05
Date: Mon, 09 Dec 2002 19:05
46 lines
2385 bytes
2385 bytes
Wojtek Walczak claimed:
> Dnia Mon, 9 Dec 2002 17:34:25 +0100, Marcin Wojtczuk napisał(a):
>> import os
>> i robić self.os.cośtam.
> Mozesz pokazac przyklad, gdzie robisz self.os.costam() ? ;]
Proszę ;)
#v+
class dns:
import re, socket
def resolve(self, host):
if self.re.match('^[0-9]', host.split('.')[0]):
try:
rev = self.socket.gethostbyaddr(host)
h = host.split('.')
i = len(h)-1
arpa = ''
while i>=0:
arpa, i = arpa + h[i] + '.', i-1
return "%sin-addr.arpa domain name pointer %s." % (arpa, rev[0])
except:
return 'Unknown host'
else:
try:
answer = self.socket.gethostbyname_ex(host)
if len(answer[1])==0:
return "%s has inet address %s" % (host, answer[2][0])
elif len(answer[1]) > 0:
s =''
for x in answer[1]:
s += "%s is an alias for %s\n" % (x, answer[0])
s += "%s has inet address %s" % (answer[0], answer[2][0])
return s
else:
raise 'socket library sucks'
except:
return "Host addr not found (NXDOMAIN)"
#v-
PS: Jak oceniacie moje postępy w nauce (tygodniowe od zera) ?
--
[ http://www.stringi.com/viper/ ]
[ JID: FastViper@jabber.gda.pl ]
All good things come to those who wait
Technical Details
Message-ID:
<9hp2ta-ui6.ln@fastviper.viper.lan>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.man.poznan.pl!news.telbank.pl!fastviper.viper.lan!newsReferences:
<37ersa-64l.ln@fastviper.viper.lan> <astj5c$3h1$1@news.tpi.pl> <2f1usa-ho9.ln@fastviper.viper.lan> <asvdcg$2a0$1@news.tpi.pl> <vv20ta-og2.ln@fastviper.viper.lan> <slrnav7jk5.col.qrczak@qrnik.zagroda> <hmg2ta-2i5.ln@fastviper.viper.lan> <slrnauve28.kb.gminick@hannibal.localdomain>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!news.man.poznan.pl!news.telbank.pl!fastviper.viper.lan!news From: Marcin Wojtczuk <fastviper@telkab.pl> Newsgroups: pl.comp.lang.python Subject: Re: połączenia http - ściąganie plików Date: Mon, 9 Dec 2002 20:05:13 +0100 Organization: PLD Lines: 46 Message-ID: <9hp2ta-ui6.ln@fastviper.viper.lan> References: <37ersa-64l.ln@fastviper.viper.lan> <astj5c$3h1$1@news.tpi.pl> <2f1usa-ho9.ln@fastviper.viper.lan> <asvdcg$2a0$1@news.tpi.pl> <vv20ta-og2.ln@fastviper.viper.lan> <slrnav7jk5.col.qrczak@qrnik.zagroda> <hmg2ta-2i5.ln@fastviper.viper.lan> <slrnauve28.kb.gminick@hannibal.localdomain> NNTP-Posting-Host: net2-3.telkab.pl Mime-Version: 1.0 X-Trace: news.telbank.pl 1039460886 27599 195.136.7.130 (9 Dec 2002 19:08:06 GMT) X-Complaints-To: usenet@news.telbank.pl NNTP-Posting-Date: 9 Dec 2002 19:08:06 GMT X-Licznik: 1626 User-Agent: slrn/0.9.7.4 (pl-1.4.3) (Linux/2.4.19pk-ll (i686)) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit