Beispiel #1
0
def add_category(page):
    if mavri.content_of_page(wiki, page):
        ENpage = mavri.wbgetlanglink(mavri.wikibase_item(wiki, page), 'enwiki')
        if ENpage:
            print ENpage
            ENcat = mavri.categories_on_enwiki(ENpage)
            print ENcat
            cat_to_add = []
            for cat in ENcat:
                ncat = mavri.wbgetlanglink(mavri.wikibase_item('en.wikipedia', 'Category:' + cat), wikiS)
                if ncat != '':
                    cat_to_add.insert(0, ncat)
            print cat_to_add
            content = mavri.content_of_page(wiki, page)
            appendtext = ''
            for cat in cat_to_add:
                if re.findall(r'\[\[\s?' + cat + '\s?\|?[^\[\]]*\]\]', content) == []:
                    appendtext += '\n[[' + cat + ']]'

            if appendtext:
                content += appendtext
                content = re.sub(r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}\s?\n?', '', content)
                content = re.sub(r'\{\{\s?[Uu]ncategorized[^\}]*\}\}\s?\n?', '', content)
                diff = mavri.change_page(wiki, page, content, '++' + catNS, xx).json()['edit']['newrevid']
                mavri.appendtext_on_page(wiki, 'Kullanıcı:Mavrikant_Bot/Log/Kategorisiz',
                                         '\n# [[Special:Diff/' + str(diff) + '|' + page + ']]',
                                         '[[Special:Diff/' + str(diff) + '|' + page + ']]', xx)
    except:
        nextpage = 'DONE'

    for line in soup.find("div", {"id": "mw-content-text"}).ul.find_all('li'):
        incele = line.find_all('a')[2].get('href')
        title = line.find_all('a')[0].get('title')
        incele_text = requests.get(trwiki + incele, cookies=xx.cookies).text

        if incele_text.find('diff-multi') == -1:
            diff = incele_text.split('<input id="mw-fr-input-oldid" type="hidden" value="')[1].split('"')[0]
            print title
            # print diff
            damaging = \
                requests.get('http://ores.wmflabs.org/scores/trwiki/damaging/' + str(diff)).json()[str(diff)][
                    'probability'][
                    'true'] * 100
            reverted = \
                requests.get('http://ores.wmflabs.org/scores/trwiki/reverted/' + str(diff)).json()[str(diff)][
                    'probability'][
                    'true'] * 100
            # print damaging
            # print reverted
            RAPOR += '\n|-\n| [https://tr.wikipedia.org' + incele + ' ' + title + '] || ' + str(damaging).replace('.',
                                                                                                                  ',') + ' || ' + str(
                reverted).replace('.', ',')

RAPOR += '\n|}'

print mavri.change_page('tr.wikipedia', 'Kullanıcı:Mavrikant/ORES', RAPOR, 'ORES', xx).text
exit(0)
Beispiel #3
0
import mavri

wiki = 'tr.wikipedia'
xx = mavri.login(wiki, 'Mavrikant')
content = requests.get('https://tr.wikipedia.org/wiki/%C3%96zel:BozukY%C3%B6nlendirmeler').text
soup = BeautifulSoup(content, 'html.parser')

for line in soup.find("div", {"id": "mw-content-text"}).ol.find_all('li'):
    page = line.find_all('a')[0].get('title')
    print page
    pagetext = mavri.content_of_page(wiki, page)
    print pagetext
    if pagetext != '':
        sil = re.findall('\{\{\s?[Ss]il[^\}]*\}\}', pagetext)
        print sil
        redirect = re.findall('\[\[\s?([^\]]*)\s?\]\]', pagetext)
        print redirect
        if redirect:
            redirectpagetext = mavri.content_of_page(wiki, redirect[0])
            print redirectpagetext
            if redirectpagetext == '' and not sil:
                HS = '{{Sil | Y1. Var olmayan sayfalara olan yönlendirmeler silinebilir. --~~~~}}\n\n'
                mavri.change_page('tr.wikipedia', page, HS + pagetext, '+ Hızlı sil, var olmayan sayfaya yönlendirme',
                                  xx)
                mavri.appendtext_on_page('tr.wikipedia', 'Kullanıcı:Mavrikant/Log/BrokenRedirects',
                                         '\n* [[' + page + ']] -> [[' + redirect[0] + ']]',
                                         '[[' + page + ']] -> [[' + redirect[0] + ']]', xx)

exit(0)
                preArchiveContent = mavri.content_of_page(
                    wiki, preArchivePage.decode('UTF-8'))
                hasBeenPreArchived = '{{Vikipedi:Silinmeye aday sayfalar/' + page + '}}' in preArchiveContent
                hasBeenArchived = '{{Vikipedi:Silinmeye aday sayfalar/' + page + '}}' in archiveContent

                if hasBeenArchived == False and hasBeenPreArchived == False:
                    append = '\n' + '{{Vikipedi:Silinmeye aday sayfalar/' + page + '}}'
                    archiveSummary = 'Arşiv sayfalarında bulunmayan [[Vikipedi:Silinmeye_aday_sayfalar/' + page + '|SAS alt sayfası]] arşivlere ekleniyor - ' + summary_ek
                    mavri.appendtext_on_page(wiki, archivePage.decode('UTF-8'),
                                             append, archiveSummary, xx)
                    print(page + ' arşiv sayfasına eklendi.')

                if pinned == False:
                    if resolved and youngestDiff.total_seconds() >= 3600:
                        summary = '[[Vikipedi:Silinmeye_aday_sayfalar/' + page + '|Sonuçlandırılan SAS]] arşivleniyor - ' + summary_ek
                        print(page + " SAS sayfasından kaldırılıyor.")
                        newContent = content.replace(
                            "{{Vikipedi:Silinmeye aday sayfalar/" + page +
                            "}}", "")
                        newContent = re.sub(r"^[ \t]*$\r?\n",
                                            "",
                                            newContent,
                                            flags=re.MULTILINE)
                        mavri.change_page(wiki, title, newContent, summary, xx)
                else:
                    print(page + ' sabitlenmiş.')
            except ValueError:
                pass
    else:
        time.sleep(60)
Beispiel #5
0
        incele = line.find_all('a')[2].get('href')
        title = line.find_all('a')[0].get('title')
        incele_text = requests.get(trwiki + incele, cookies=xx.cookies).text

        if incele_text.find('diff-multi') == -1:
            diff = incele_text.split(
                '<input id="mw-fr-input-oldid" type="hidden" value="'
            )[1].split('"')[0]
            print title.encode('UTF-8')
            # print diff
            damaging = \
                requests.get('http://ores.wmflabs.org/v3/scores/trwiki/' + str(diff) + "/damaging").json()["trwiki"]["scores"][str(diff)][
                    "damaging"]["score"]["probability"][
                    "true"] * 100
            goodfaith = \
                requests.get('http://ores.wmflabs.org/v3/scores/trwiki/' + str(diff) + "/goodfaith").json()["trwiki"]["scores"][str(diff)][
                    "goodfaith"]["score"]["probability"][
                    "true"] * 100
            # print damaging
            # print reverted
            RAPOR += '\n|-\n| [https://tr.wikipedia.org' + incele + ' ' + title + '] || ' + str(
                damaging).replace('.', ',') + ' || ' + str(goodfaith).replace(
                    '.', ',')
            if counter % 10 == 0:
                print mavri.change_page('tr.wikipedia',
                                        'Kullanıcı:Evrifaessa/ORES', RAPOR,
                                        'ORES raporu yazılıyor', xx).text
            counter += 1
RAPOR += '\n|}'

exit(0)
Beispiel #6
0
kaynak = ilk + randint(0, int(str(bugun - ilk).split(' days')[0])) * one_day

Log_page = 'Kullanıcı:Mavrikant Bot/Log/Günün Maddesi'


if (yarin.strftime("%d") == '01'):  # Yeni ay temizliği
    mavri.page_clear(wiki, Log_page, 'Yeni ay temizliği', xx)

YARIN = mavri.content_of_page(wiki, 'Şablon:GM/' + yarin.strftime("%Y-%m-%d"))

if (YARIN == ''):  # yarın boş
    Summary = 'Olumsuz'
    Durum = '\n* {{Çapraz}}'

    # Kaynak söz bul ve al
    KAYNAK = ''
    while KAYNAK == '':
        KAYNAK = mavri.content_of_page(wiki, 'Şablon:GM/' + kaynak.strftime("%Y-%m-%d"))
        kaynak += one_day

    # Kaynak söz ile yarını oluştur
    mavri.change_page(wiki, 'Şablon:GM/' + yarin.strftime("%Y-%m-%d"), KAYNAK,
                       '[[Şablon:GM/' + kaynak.strftime("%Y-%m-%d") + ']] sayfasından kopyalandı.', xx)

else:  # yarın dolu
    Summary = 'Olumlu'
    Durum = '\n* {{Tamam}}'

Durum += ' [[Şablon:GM/' + yarin.strftime("%Y-%m-%d") + ' | \'\'\'' + yarin.strftime("%d.%m.%Y") + '\'\'\']]'

mavri.sent_message(wiki, Log_page, Durum, Summary+' (WMF-Labs)', xx)
Beispiel #7
0
# -*- coding: utf-8 -*-

import mavri
import requests
from bs4 import BeautifulSoup
import re
xx = mavri.login('tr.wikipedia', 'Mavrikant Bot')

while 1:
    soup = BeautifulSoup(requests.get(
        'https://tr.wikipedia.org/w/index.php?title=%C3%96zel:Ba%C4%9FArama&limit=500&offset=0&target=http%3A%2F%2Fwww.mackolik.com%2FFutbolcu',
        cookies=xx.cookies).text, 'html.parser')

    for line in soup.find("ol", {"class": "special"}).find_all('li'):
        title = line.find_all('a')[1].get('title')
        print title
        content = mavri.content_of_page('tr.wikipedia', title)
        content = re.sub(r'\[\s?http://www.mackolik.com/Futbolcu/(\d*)[^\]]*\]', r'{{Mackolik.com futbolcu|\1}}',
                         content)

        mavri.change_page('tr.wikipedia', title, content, 'mackolik.com linkleri şablona dönüştürüldü', xx)
Beispiel #8
0
def add_category(page):
    print page
    content = mavri.content_of_page(wiki, page)
    if content:
        if re.findall(r'\[\[\s?' + catNS + '[^\]]*\]\]', content) != []:
            content = re.sub(r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}\s?\n?', '',
                             content)
            content = re.sub(r'\{\{\s?[Uu]ncategorized[^\}]*\}\}\s?\n?', '',
                             content)
            return mavri.change_page(wiki, page, content,
                                     '- Kategorisiz Şablonu', xx)

        entity = mavri.wikibase_item(wiki, page)
        langs = mavri.wbgetlangsofentity(entity)
        langs = re.findall(r'\'([a-z]{2,3})wiki\'', str(langs))
        if 'tr' in langs: langs.remove('tr')
        print langs
        if langs:
            lang = random.choice(langs)
            Swiki = lang + '.wikipedia'
            Slang = lang + 'wiki'
            print Swiki
            print Slang
            Spage = mavri.wbgetlanglink(entity, Slang)
            print Spage
            Scat = mavri.categories_on_page(Swiki, Spage)
            print Scat
            ScatNS = requests.get(
                'https://' + Swiki +
                '.org/w/api.php?format=json&utf8=&action=query&meta=siteinfo&siprop=namespaces'
            ).json()['query']['namespaces']['14']['*']

            cat_to_add = []
            for cat in Scat:
                ncat = mavri.wbgetlanglink(
                    mavri.wikibase_item(Swiki, ScatNS + ':' + cat), 'trwiki')
                print cat + ' -> ' + ncat
                if ncat != '':
                    cat_to_add.insert(0, ncat)
            print cat_to_add
            content = mavri.content_of_page(wiki, page)
            appendtext = ''
            for cat in cat_to_add:
                if re.findall(r'\[\[\s?' + cat + '\s?\|?[^\[\]]*\]\]',
                              content) == []:
                    appendtext += '\n[[' + cat + ']]'

            NUM = str(len(cat_to_add))
            if appendtext:
                content += appendtext
                content = re.sub(r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}\s?\n?', '',
                                 content)
                content = re.sub(r'\{\{\s?[Uu]ncategorized[^\}]*\}\}\s?\n?',
                                 '', content)
                diff = \
                    mavri.change_page(wiki, page, content, '+ ' + NUM + catNS + ', Kaynak=' + Slang, xx).json()['edit'][
                        'newrevid']
                mavri.appendtext_on_page(
                    wiki, 'Kullanıcı:Mavrikant_Bot/Log/Kategorisiz',
                    '\n# [[Special:Diff/' + str(diff) + '|' + page + ']] (+ ' +
                    NUM + catNS + ', Kaynak=' + Slang + ')',
                    '[[Special:Diff/' + str(diff) + '|' + page + ']] (+ ' +
                    NUM + catNS + ', Kaynak=' + Slang + ')', xx)
            else:
                content = mavri.content_of_page(wiki, page)
                if re.findall(r'\[\[\s?' + catNS + '[^\]]*\]\]',
                              content) == [] and re.findall(
                                  r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}',
                                  content) == []:
                    content = re.sub(r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}\s?\n?',
                                     '', content)
                    content = re.sub(
                        r'\{\{\s?[Uu]ncategorized[^\}]*\}\}\s?\n?', '',
                        content)
                    diff = mavri.change_page(
                        wiki, page, content +
                        '\n\n{{Kategorisiz|{{kopyala:CURRENTMONTHNAME}} {{kopyala:CURRENTYEAR}}}} ',
                        '+ Kategorisiz Şablonu', xx).json()['edit']['newrevid']
                    mavri.appendtext_on_page(
                        wiki, 'Kullanıcı:Mavrikant_Bot/Log/Kategorisiz',
                        '\n# [[Special:Diff/' + str(diff) + '|' + page +
                        ']] (Kategorisiz)', '[[Special:Diff/' + str(diff) +
                        '|' + page + ']] (Kategorisiz)', xx)
        else:
            content = mavri.content_of_page(wiki, page)
            if re.findall(r'\[\[\s?' + catNS + '[^\]]*\]\]',
                          content) == [] and re.findall(
                              r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}',
                              content) == []:
                content = re.sub(r'\{\{\s?[Kk]ategorisiz[^\}]*\}\}\s?\n?', '',
                                 content)
                content = re.sub(r'\{\{\s?[Uu]ncategorized[^\}]*\}\}\s?\n?',
                                 '', content)
                diff = mavri.change_page(
                    wiki, page, content +
                    '\n\n{{Kategorisiz|{{kopyala:CURRENTMONTHNAME}} {{kopyala:CURRENTYEAR}}}} ',
                    '+ Kategorisiz Şablonu', xx).json()['edit']['newrevid']
                mavri.appendtext_on_page(
                    wiki, 'Kullanıcı:Mavrikant_Bot/Log/Kategorisiz',
                    '\n# [[Special:Diff/' + str(diff) + '|' + page +
                    ']] (Kategorisiz)', '[[Special:Diff/' + str(diff) + '|' +
                    page + ']] (Kategorisiz)', xx)
Beispiel #9
0
                    wiki, page, content +
                    '\n\n{{Kategorisiz|{{kopyala:CURRENTMONTHNAME}} {{kopyala:CURRENTYEAR}}}} ',
                    '+ Kategorisiz Şablonu', xx).json()['edit']['newrevid']
                mavri.appendtext_on_page(
                    wiki, 'Kullanıcı:Mavrikant_Bot/Log/Kategorisiz',
                    '\n# [[Special:Diff/' + str(diff) + '|' + page +
                    ']] (Kategorisiz)', '[[Special:Diff/' + str(diff) + '|' +
                    page + ']] (Kategorisiz)', xx)


# Section 1
cats = mavri.pages_on_category(wiki, 'Kategori:Kategorisiz')
for line in cats:
    page = line['title']
    add_category(page)

# Section 2
content = requests.get(
    'https://' + wiki +
    '.org/w/api.php?action=query&format=json&utf8&list=querypage&qppage=Uncategorizedpages&qplimit=500'
)
datelog = 'Kullanıcı:Mavrikant_Bot/Log/Kategorisiz/Tarih'
olddate = mavri.content_of_page(wiki, datelog)
newdate = content.json()['query']['querypage']['cachedtimestamp']

if olddate != newdate:
    mavri.change_page(wiki, datelog, newdate, newdate, xx)
    for line in content.json()['query']['querypage']['results']:
        page = line['title']
        add_category(page)
Beispiel #10
0
kaynak = ilk + randint(0, int(str(bugun - ilk).split(' days')[0])) * one_day

Log_page = 'Kullanıcı:Mavrikant Bot/Log/Günün Sözü'

if (yarin.strftime("%d") == '01'):  # Yeni ay temizliği
    mavri.page_clear(wiki, Log_page, 'Yeni ay temizliği', xx)

YARIN = mavri.content_of_page(wiki, 'Vikisöz:Günün sözü/' + yarin.strftime("%Y/%m/%d"))

if (YARIN == ''):  # yarın boş
    Summary = 'Olumsuz'
    Durum = '\n* {{Çapraz}}'

    # Kaynak söz bul ve al
    KAYNAK = mavri.content_of_page(wiki, 'Vikisöz:Günün sözü/' + kaynak.strftime("%Y/%m/%d"))
    while KAYNAK == '':
        kaynak += one_day
        KAYNAK = mavri.content_of_page(wiki, 'Vikisöz:Günün sözü/' + kaynak.strftime("%Y/%m/%d"))

    # Kaynak söz ile yarını oluştur
    mavri.change_page(wiki, 'Vikisöz:Günün sözü/' + yarin.strftime("%Y/%m/%d"), KAYNAK,
                      '[[Vikisöz:Günün sözü/' + kaynak.strftime("%Y/%m/%d") + ']] sayfasından kopyalandı.', xx)

else:  # yarın dolu
    Summary = 'Olumlu'
    Durum = '\n* {{Tamam}}'

Durum += ' [[Vikisöz:Günün sözü/' + yarin.strftime("%Y/%m/%d") + ' | \'\'\'' + yarin.strftime("%d.%m.%Y") + '\'\'\']]'

mavri.sent_message(wiki, Log_page, Durum, Summary + ' (WMF-Labs)', xx)