您的位置:首页 > 编程语言 > Python开发

Python 刷网站流量脚本

2020-02-02 18:04 1656 查看

说明

作弊可耻!

环境

python3.8 + selenium + 动态ip(或单窗口单ip)

代码

#-*- coding:utf-8 -*-
from selenium import webdriver
import time,requests,random
from selenium.common.exceptions import NoSuchElementException
chromeOptions = webdriver.ChromeOptions()

i = 0
while True:
#免费IP池的话设置在下方,这边本地使用了单窗口单ip所以注销
#ip = 'http://' + requests.get('http://localhost:5555/random').text
# 设置代理
#chromeOptions.add_argument("--proxy-server=%s"%ip)
chromeOptions.add_argument('--headless')
chromeOptions.add_argument('--disable-gpu')
b = webdriver.Chrome(options = chromeOptions)
try:
b.get("目标网站")
time.sleep(2)
for k in range(1,5):
j = random.randint(1,10)
b.find_element_by_xpath('随机开几个网站div[{}]/ul/li[{}]/a'.format(k,j)).click()
time.sleep(3)
b.find_element_by_link_text("随机点几个栏目").click()
j = random.randint(1,10)
b.find_element_by_xpath('随机开几个网站ul[1]/li[{}]/a'.format(j)).click()
time.sleep(5)
b.find_element_by_link_text('随机点几个栏目').click()
time.sleep(3)
i += 1
print('已刷新--',i,'--次')
except Exception as e:
print(e)
b.quit()

使用说明

  1. 免费ip可自行搭建IP池
  2. 本案例之前采用的单窗口单ip,新建一个bat文件将脚本开N个进程一起刷贼快。
  3. 也可以使用动态IP但只能单进程刷。
    单窗口单IP刷量是动态IP的N倍。
  • 点赞
  • 收藏
  • 分享
  • 文章举报
aosky 发布了5 篇原创文章 · 获赞 0 · 访问量 261 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: