Кулланучы:Marat-avgust/Рейтинг клубов КОНМЕБОЛ/Ә

Wikipedia — ирекле энциклопедия проектыннан ([http://tt.wikipedia.org.ttcysuttlart1999.aylandirow.tmf.org.ru/wiki/Marat-avgust/Рейтинг клубов КОНМЕБОЛ/Ә latin yazuında])

def GetDate(): import datetime

return datetime.date.today() def GetTable(): import urllib2

from BeautifulSoup import BeautifulSoup

url = u'http://df1.conmebol.com/ranking/ranking_completo.html'

print u"Retrieving " + url webpage = urllib2.urlopen(url) # Чтение веб-страницы print u"\nDone!"

soup = BeautifulSoup(webpage)

tbody = soup.find(attrs={'class': 'tbody'}).findAll('tr') # Выделение «тела» интересующей нас таблицы

table = [] for tr in tbody: tds = tr.findAll('td') table.append([tds[0].span.contents[0].replace('º',), tds[1].span.contents[0], tds[1].span.span.contents[0], tds[2].span.contents[0]]) # формирование элемента списка return table def TtWikification(): import re site = wikipedia.getSite('tt', 'wikipedia')

page = wikipedia.Page(site, u'Кулланучы:Marat-avgust/Рейтинг клубов КОНМЕБОЛ/Замена') text = page.get()

wikipedia.stopme()

d = {} for line in text.splitlines(): en_name = re.findall('(?<=:).*(?=[=])', line)[0] tt_name = re.findall('(?<=[=]).*', line)[0] d[en_name] = tt_name

return d def MakeContent(table, date): content = u"

Клуб Очки\n"

for item in table: content += u"|- style="background:#Төзмә хата: билгесез символ «"»"

" + item[0] + " " + item[2].replace('(','Калып:').replace(')','') + " {{{4}}}\n"

content += u"|- style="text-align:center; background-color:#EEEEFF;"

Обновлено " + str(date.strftime('Төзмә хата: билгесез символ «%» %Y ел')).decode('utf8') + "

" content += u"\n

Документация Документация

\n"

return content def WriteToWP(content): site = wikipedia.getSite('tt', 'wikipedia')

page = wikipedia.Page(site, u'Кулланучы:Marat-avgust/Рейтинг клубов КОНМЕБОЛ') page.put(content, comment=u'Обновление рейтинга клубов КОНМЕБОЛ')

wikipedia.stopme() import wikipedia

date = GetDate()

table = GetTable() content = MakeContent(table, date)

WriteToWP(content)