如何优雅的提高博客访问量?

如何优雅的提高博客访问量?

伊始 兴致勃勃的写了几篇博客,访问量几个几个的慢慢增长,看着别人几十万的访问,心里难免有点失望毕竟现在是流量时代了,没有流量啥也不是,正所谓“酒香也怕巷子深”!于是乎想着先把访问量搞上去再说。

准备 网上找了很多类似的案例,发现问题很多,经过学习与研究,完成了两种稳定的方法可以提高访问量,分别是基于Java和python的,在网络稳定的情况下,一天可以增加3万左右的访问。

实现 方法1(python): 需要使用浏览器的***,查看方法是直接在浏览器地址栏中输入

about:version

结果如下: 其中所需要的是用户***,复制备用。

import requests

import time

url = [#这里是你博客的地址,多个之间使用逗号隔开

'https://blog.csdn.net/huanglei305/article/details/100891385',

'https://blog.csdn.net/huanglei305/article/details/100883322']

#刚刚复制的那个用户***,替换掉就可以

headers = {

'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'}

count = 0

countUrl = len(url)

# 访问次数设置,超过之后程序停止

while count < 100000:

try: # 正常运行

for i in range(countUrl):

response = requests.get(url[i], headers=headers)

if response.status_code == 200:

count = count + 1

print('成功访问 ' + str(count), '次')

time.sleep(60)

except Exception: # 异常情况

print('访问出现异常请稍等!')

time.sleep(5)

跑了一晚上,结果就是这样的: 方法2(Java): 这个方法需要使用IP***,缺点就是免费的IP不稳定,想要稳定就要购买,实测在芝麻HTTP每天可以免费领取20个稳定的IP,可以刷半小时,增加5k左右的访问,也是个不错的选择,感兴趣的可以试试。 代码如下:

package com.hbut.csdn;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.URL;

import java.util.HashSet;

import java.util.Properties;

public class CSDN {

private String zhuye;

private String sousuo="/article/details/";

public CSDN(){

//修改成你自己的博客主页

zhuye="https://blog.csdn.net/huanglei305";

}

public CSDN(String url){

zhuye=url;

}

public String getZhuye() {

return zhuye;

}

public void setZhuye(String zhuye) {

this.zhuye = zhuye;

}

public String getSousuo() {

return sousuo;

}

public void setSousuo(String sousuo) {

this.sousuo = sousuo;

}

public String open(String url){

StringBuffer str=new StringBuffer();

BufferedReader in=null;

try {

URL u=new URL(url);

in=new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8"));

while(true){

String s=in.readLine();

if(s==null)break;

else str.append(s);

}

} catch (IOException e) {

e.printStackTrace();

}finally{

try {

if(in!=null)in.close();

} catch (IOException e) {

e.printStackTrace();

}

}

return str.toString();

}

public HashSet sousuoHTML(String str){

HashSet set=new HashSet();

int st,end;

while((st=str.indexOf(zhuye+sousuo))!=-1){

if((end=str.indexOf("\"", st))!=-1){

String s=str.substring(st, end);

if(s.indexOf("#comments")!=-1){

s=s.substring(0,s.indexOf("#comments"));

}

set.add(s);

str=str.substring(end);

}

}

return set;

}

public int getFangke() {

String str=open(zhuye);

int i;

if((i=str.indexOf("访问:"))!=-1){

str=str.substring(i);

str=str.substring(str.indexOf("\"")+1);

str=str.substring(0,str.indexOf("\""));

}

else if((i=str.indexOf("personal_list"))!=-1){

str=str.substring(i);

str.substring(str.indexOf("")+4,str.indexOf(""));

}

int ii=0;

try {

ii=Integer.parseInt(str);

} catch (NumberFormatException e) {

e.printStackTrace();

}

return ii;

}

public void daili(String ip,String dk) {

Properties prop=System.getProperties();

// 设置http访问要使用的***服务器的地址

prop.setProperty("http.proxyHost", ip);

// 设置http访问要使用的***服务器的端口

prop.setProperty("http.proxyPort", dk);

// 设置不需要通过***服务器访问的主机,可以使用*通配符,多个地址用|分隔

prop.setProperty("http.nonProxyHosts", "localhost|192.168.168.*");

// 设置安全访问使用的***服务器地址与端口

// 它没有https.nonProxyHosts属性,它按照http.nonProxyHosts 中设置的规则访问

prop.setProperty("https.proxyHost", ip);

prop.setProperty("https.proxyPort", dk);

// 使用ftp***服务器的主机、端口以及不需要使用ftp***服务器的主机

prop.setProperty("ftp.proxyHost", ip);

prop.setProperty("ftp.proxyPort", dk);

prop.setProperty("ftp.nonProxyHosts", "localhost|192.168.168.*");

// socks***服务器的地址与端口

prop.setProperty("socksProxyHost", ip);

prop.setProperty("socksProxyPort", dk);

System.out.println("当前使用ip地址:"+ip+" :"+dk);

}

//获取的IP,多个之间使用逗号隔开。

public static String[]dl= {"58.218.200.237:3418",

"58.218.200.237:3645"};

public static void main(String[] args) {

int i=0;

CSDN csdn=new CSDN();

while(true) {

long a=System.currentTimeMillis();

for(i=0;i

String[]dd=dl[i].split(":");

csdn.daili(dd[0], dd[1]);

HashSet set=csdn.sousuoHTML(csdn.open(csdn.getZhuye()));

for(String url:set){

csdn.open(url);

System.out.println("正在打开地址:"+url);

}

System.out.println("电脑已访问"+(++i));

System.out.println("访问量:"+csdn.getFangke());

}

long b=System.currentTimeMillis();

long c=b-a;

if(3500-c>0) {

try {

Thread.sleep(3500-c);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

}

更多创意作品