其实我这篇博文就是刷了一下csdn的浏览量。

代码如下:

import pyautogui
import time

targetX1 = 600
targetY1 = 300
targetX2 = 600
targetY2 = 400
targetX3 = 600
targetY3 = 500
sleep_t = 1
distance=10000

def SelectBlog(y):
if y == 0:
pyautogui.moveTo(targetX1,targetY1)
elif y == 1:
pyautogui.moveTo(targetX2,targetY2)
else:
pyautogui.moveTo(targetX3,targetY3)

def OpenBlog():
pyautogui.click()
time.sleep(sleep_t)

def ScanBlog():
pyautogui.scroll(-10)
pyautogui.scroll(-20)
pyautogui.scroll(-30)
pyautogui.scroll(-10)
pyautogui.scroll(-20)
pyautogui.scroll(-30)
pyautogui.scroll(-10)
pyautogui.scroll(60)


def WRBlog():
pyautogui.hotkey('ctrl','w')
time.sleep(sleep_t)
pyautogui.hotkey('ctrl','R')
time.sleep(sleep_t)

while distance > 0:
i = distance % 3
distance = distance - 1

SelectBlog(i)
OpenBlog()
ScanBlog()
WRBlog()

解释:

定义了4个函数,作用以此是:选择要打开哪篇博文,打开选择的博文,移动滚动条模拟浏览,关闭和刷新网页。

targetX1 = 600
targetY1 = 300
targetX2 = 600
targetY2 = 400
targetX3 = 600
targetY3 = 500

这个是三篇博文的位置。

moveto函数是移动到指定的位置;

click是左击,rightClick是右击;

scroll是移动滚动条;

hotkey就是模拟键盘。