azatprogrammalar
:: FTP mirror, python bilen :: (764 Reads)
Posted by
gurban
on Monday, December 25, 2006 - 04:46 AM
boldum. Köp ftp program-leri ulanyp gördüm. Birisi hem
universitynyň proxy-serveri bilen öňuşup bilmedi. Bu ýerde FTP
porti baglagyly eken. Näme etmlei bor?
Birini özim ýazdym :) Python-da ftplib hem proxy-server bilen öňuşup bilmedi. urllib2-dan
ulandym, netijeler HTML suratda geldi :( . Aý näme bolsa HTML bilen
oňuşmaly boldym.
bu hem ftpmirror ködi: (LISENSE: GPL2 :)
#!/usr/bin/python
url = 'ftp://ftp.ucar.edu/mesouser/'
localdir = 'mm5'
proxy = '192.168.50.50:2323'
proxy_user = 'nic\gurban'
proxy_password = 'hummmmmm!'
import os
import re
import urllib2
import urlparse
def get_ftp(url, the_dir):
if not os.path.exists(the_dir):
os.mkdir(the_dir)
os.chdir(the_dir)
print 'CD %s' % the_dir
req = urllib2.Request(url)
data = urllib2.urlopen(req).read()
lines = data.split('\n')
items = [(line.split('"')[1], line.find('DIR') > -1)
for line in lines if re.search(r'(FILE|DIR)', line)
is not None]
for link, is_dir in items:
the_url = urlparse.urljoin(url,link)
the_path = os.path.abspath(link)
if is_dir:
if link != '../': get_ftp(the_url, the_path)
else:
print 'GET %s' % the_url
req = urllib2.Request(the_url)
data = urllib2.urlopen(req).read()
fp = file(the_path, 'wb')
fp.write(data)
fp.close()
os.chdir(the_dir)
proxy_handler = urllib2.ProxyHandler(
{'ftp': 'http://%s:%s@%s' % (proxy_user, proxy_password, proxy)}
)
opener= urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
get_ftp (url, os.path.abspath(localdir))
| FTP mirror, python bilen | Log-in or register a new user account | 1 Comment | |
|
| |
| Comments are statements made by the person that posted them. They do not necessarily represent the opinions of the site editor. |
Re: FTP mirror, python bilen(Score: 1)by bumaza391abc on Jun 06, 2008 - 02:09 AM (User information | Send a message |
| foto troie con animali gratis, storie in pps, mariti ponostar, vanessa voyeurweb, letizia bruni gratis, donne mature formose, donne bagnate over 70, chat gratuita sexy senza iscrizione, solo cartoni studentesse nude in tanga, emoticon porno free, orge amatoriali con foto, siti di videochiamate erotiche, foto sexi si serena grandi, amatoriale 69, inculate brasiliane, cerco fighe, sborrate tra le tette, trombate it, ragazzi muscolosi, ragazze sarde piccanti, |





