如何通过程序(java)提高CSDN的博客访问量

本文介绍了一个Java程序,该程序能够批量启动火狐浏览器并加载一系列指定的URL。通过使用命令行和Runtime类,程序实现了定时重启浏览器及加载多个链接的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;

public class OpenUrl {
    public static String str="taskkill /F /IM firefox.exe";
    //这里firefox也可以改为iexplore或者chrome等等,也就是指定打开网页的浏览器,后面这些参数就是网址,
    //实际上有文件来代替更好,主要是本人博客不多也懒得折腾了
    public static String str1="cmd /c start firefox "
            + "http://blog.csdn.net/u012062455/article/details/50434642 "
            + "http://blog.csdn.net/u012062455/article/details/52142258 "
            + "http://blog.csdn.net/u012062455/article/details/52347099 "
            + "http://blog.csdn.net/u012062455/article/details/52369288 "
            + "http://blog.csdn.net/u012062455/article/details/52435973 "
            + "http://blog.csdn.net/u012062455/article/details/52442838 "
            + "http://blog.csdn.net/u012062455/article/details/52454934 "
            + "http://blog.csdn.net/u012062455/article/details/52494118 "
            + "http://blog.csdn.net/u012062455/article/details/52547547 "
            + "http://blog.csdn.net/u012062455/article/details/52552183 "
            + "http://blog.csdn.net/u012062455/article/details/52614664 "
            + "http://blog.csdn.net/u012062455/article/details/52629523 "
            + "http://blog.csdn.net/u012062455/article/details/52640709 "
            + "http://blog.csdn.net/u012062455/article/details/52734888 "
            + "http://blog.csdn.net/u012062455/article/details/52734932 "
            + "http://blog.csdn.net/u012062455/article/details/52734941 "
            + "http://blog.csdn.net/u012062455/article/details/52735016 "
            + "http://blog.csdn.net/u012062455/article/details/52735065 "
            + "http://blog.csdn.net/u012062455/article/details/52735102 "
            + "http://blog.csdn.net/u012062455/article/details/52776680 "
            + "http://blog.csdn.net/u012062455/article/details/53286213 "
            + "http://blog.csdn.net/u012062455/article/details/53287643";

    //我这里把要访问的网址分成了两部分,一次性访问大概二十个左右,浏览器不敢一次打开得太多,怕爆炸
    public static String str2="cmd /c start firefox "
            + "http://blog.csdn.net/u012062455/article/details/52784932 "
            + "http://blog.csdn.net/u012062455/article/details/52785064 "
            + "http://blog.csdn.net/u012062455/article/details/52787301 "
            + "http://blog.csdn.net/u012062455/article/details/52787370 "
            + "http://blog.csdn.net/u012062455/article/details/52797354 "
            + "http://blog.csdn.net/u012062455/article/details/52805116 "
            + "http://blog.csdn.net/u012062455/article/details/53189873 "
            + "http://blog.csdn.net/u012062455/article/details/53189935 "
            + "http://blog.csdn.net/u012062455/article/details/53190068 "
            + "http://blog.csdn.net/u012062455/article/details/53190601 "
            + "http://blog.csdn.net/u012062455/article/details/53190685 "
            + "http://blog.csdn.net/u012062455/article/details/53199557 "
            + "http://blog.csdn.net/u012062455/article/details/53199662 "
            + "http://blog.csdn.net/u012062455/article/details/53200443 "
            + "http://blog.csdn.net/u012062455/article/details/53201836 "
            + "http://blog.csdn.net/u012062455/article/details/53203769 "
            + "http://blog.csdn.net/u012062455/article/details/53216898 "
            + "http://blog.csdn.net/u012062455/article/details/53217233 "
            + "http://blog.csdn.net/u012062455/article/details/53257059 "
            + "http://blog.csdn.net/u012062455/article/details/53259682 "
            + "http://blog.csdn.net/u012062455/article/details/53260177 "
            + "http://blog.csdn.net/u012062455/article/details/53261933 "
            + "http://blog.csdn.net/u012062455/article/details/53282380";

    public static ArrayList<String> strList=new ArrayList<String>();


    public OpenUrl(){
        strList.add(str1);
        strList.add(str2);
    }

    public static void main(String args[]) {
        // defaultBrowserOpenUrl();
        OpenUrl openUrl=new OpenUrl();
        while(true){
            int i = 0;
            String strUrl = "";
            while (i < 2) {
                strUrl = strList.get(i);
                openFirefoxBrowser(strUrl, str);
                //每关闭一次浏览器,等待大概30s再重启,太过频繁浏览器会爆炸
                try {
                    Thread.sleep(30000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                i++;
            }
            //遍历一次睡一个小时,一天可以跑个二十二二十三次左右
            try {
                Thread.sleep(3600000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    //使用指定的浏览器打开
    public static void openFirefoxBrowser(String start,String stop) {
        // 启用cmd运行firefox的方式来打开网址。
        try {
            Runtime.getRuntime().exec(start);
            try {
                Thread.sleep(60000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Runtime.getRuntime().exec(stop);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    //使用操作系统默认的浏览器打开
        private static void defaultBrowserOpenUrl() {
            // ...
            try {
                Desktop.getDesktop().browse(new URI("http://blog.csdn.net/u012062455/article/details/52369288"));
            } catch (IOException | URISyntaxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } // 网址被屏蔽了,手动加网址试一下。
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值