Користувач:BaseBot/changeroffiles

Матеріал з Вікіпедії — вільної енциклопедії.
Перейти до навігації Перейти до пошуку
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commonsbasebot;

import java.util.LinkedHashMap;
import net.wikipedia.Wiki;

/**
 *
 * @author Base
 */
public class CommonsBaseBot {

    /**
     * @param args the command line arguments
     */
     public static void main(String[] args) throws Exception {
        Wiki wiki = new Wiki("uk.wikipedia.org");
        wiki.login("login", "password");
        wiki.setUserAgent("commons bot");
        int limit = 50;
        int section=1;
        wiki.setMarkBot(true);
        wiki.setMarkMinor(true);
        wiki.
        String[] wth = wiki.imageUsage("F1_logo.svg");
        System.out.println("wth.length="+wth.length);
        for(int i=0; i<wth.length; i++){
            System.out.println("Робота над сторінкою:"+wth[i]);
            String pt=wiki.getPageText(wth[i]);
            
            
            pt=pt.replaceAll("F1 logo.svg", "Alonso-WPF1logo.png");
            pt=pt.replaceAll("\\[\\[File:", "[[Файл:");
            pt=pt.replaceAll("\\[\\[Зображення:", "[[Файл:");
            pt=pt.replaceAll("\\[\\[Image:", "[[Файл:");
            wiki.edit(wth[i], pt, "F1_logo.svg => Painting, sculpture & Alonso-WPF1logo.png та префіксів у включеннях Alonso-WPF1logo.png - потрушення фейрюзу");
        
              }
        wiki.logout();
        
        
      
    }
     
         public static String replaceAll(String str, String pattern, String replace) {
        int s = 0;
        int e = 0;
        StringBuffer result = new StringBuffer();
        while ((e = str.indexOf(pattern, s)) >= 0) {
            result.append(str.substring(s, e));
            result.append(replace);
            s = e + pattern.length();
        }
        result.append(str.substring(s));
        return result.toString();
    }
}