[ubuntu-it-www] Re: Problema sulle news
Leo Iannacone
leo.iannacone at gmail.com
Thu May 20 22:40:02 BST 2010
Il giorno gio, 20/05/2010 alle 16.18 +0200, Leo Iannacone ha scritto:
> Il 20 maggio 2010 14.23, Fabio Marzocca <thesaltydog at gmail.com> ha scritto:
> > A me pare che adesso dal planet si accede bene alle news del sito.
>
> Planet via web sì.
>
> Planet via feed no... Ci vuole uno script sul server che fa il replace
> dei '&' con '&'.
Per ora risolvo con questo script che ho messo nel cronjob sul server.
Praticamente macina tutti i file (vedi "files") generati dal planet alla
ricerca di '&amp;' e lo sostituisce con '&'.
Così risolviamo temporaneamente.
Ma resta il fatto che bisogna capire cosa c'è che non va nel sito.
#!/usr/bin/env python
# This script is used to fix uris from
# ubuntu-it.org website News feed
# replacing '&amp;' with '&'
from re import findall
from re import MULTILINE
base = '/srv/planet.ubuntu-it.org/www/'
files = [
'atom.xml',
'foafroll.xml',
'index.html',
'opml.xml',
'rss10.xml',
'rss20.xml'
]
# Pattern
url_base = "http://www.ubuntu-it.org/index.php?mact=News"
for f in files:
# print ("Opening %s..." % f)
absolute = base + f
fd = open(absolute, 'r')
data = fd.read()
fd.close()
urls = findall(url_base.replace('?','\?') + "(.*)", data, MULTILINE)
for url in urls:
fix = url.replace('&amp;', '&')
data = data.replace(url_base + url, url_base + fix)
fd = open(absolute, 'w')
fd.write(data)
fd.close()
More information about the Gruppo-web
mailing list