Το καλύτερο που μπορώ να κάνω (με το χρόνο που έχω) είναι αυτό:
- Κώδικας: Επιλογή όλων
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#filename: converturlsparse.py
#==================================================================================
# Copyright:
#
# Copyright (C) 2014 Konstas Marmatakis <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.
"""
import urllib.parse
#Διάβασε το αρχείο με τους συνδέσμους.
fh = open('urls.txt', 'r')
urlsfromtxt = fh.read()
fh.close()
del(fh)
#Άνοιξε το html αρχείο για γράψιμο.
fh = open('urls.html', 'w')
#Γράψε τις επικεφαλίδες του αρχείου.
fh.write('''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml">
<head>\n
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>\n''')
#Επεξεργάσου έναν - έναν τους συνδέσμους.
# Αφαίρεσε την τελική κάθετο.
#Αφαίρεσε τους ειδικούς χαρακτήρες από το σύνδεσμο και
#χώρισε τον.
#Γράψε τον σύνδεσμο με περιγραφή στο html αρχείο.
for url in urlsfromtxt.splitlines():
url = url.strip('/')
url = urllib.parse.unquote(url)
spurl = urllib.parse.urlsplit(url)
titlos = spurl.path
titlos = titlos.replace('-', ' ')
titlos = titlos.strip('/')
fh.write("<a href={0}>{1}</a></br>\n".format(url, titlos.capitalize()))
#Κλείσε το αρχείο.
fh.write('</html>\n')
fh.close()
Επίσης το ερώτημα GET στον σύνδεσμο μπορεί να έχει διάφορες ονομασίες, ανάλογα με το όνομα της μεταβλητής που θα δώσει ο προγραμματιστής της ιστοσελίδας.

