Δημοσιεύτηκε: 17 Σεπ 2014, 22:50
Lionux έγραψε:Ευχαριστως κ σε python !!!
Με πιο τροπο λοιπον μπορει να διαβασει η python το url.txt αρχειο που εχω !
Έτοιμο.
- Κώδικας: Επιλογή όλων
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#==================================================================================
# Copyright:
#
# Copyright (C) 2014 kamar <marmako[at]gmail[dot]com>
#
# License:
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#===============================================================================
"""
Μετατροπή συνδέσμων από αρχείο txt σε αρχείο html, με δημιουργία
τίτλου.
Το αρχείο urls.txt πρέπει να βρίσκεται στον ίδιο κατάλογο με το
script.
"""
fh = open('urls.txt', 'r')
urlsfromtxt = fh.read()
fh.close()
del(fh)
fh = open('urls.html', 'w')
for line in urlsfromtxt.splitlines():
line = line.rstrip('/')
titlos = line.split('/')[-1]
titlos = titlos.replace('-', ' ')
fh.write("<a href={0}>{1}</a></br>\n".format(line, titlos.capitalize()))
fh.close()