日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python刷阅读_通过python+selenium3实现浏览器刷简书文章阅读量

發布時間:2023/12/2 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python刷阅读_通过python+selenium3实现浏览器刷简书文章阅读量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

準備工作

下載python,本文以python3.6為例。python3.6下載地址:python3下載地址,選擇合適的版本安裝。安裝成功后,打開命令提示符,在其中輸入python,顯示如下信息,則說明安裝成功。

C:\Users\Ubuntu>python

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>>

安裝selenium3,打開命令提示符,輸入pip install selenium,selenium會自動下載安裝。安裝完成后,打開命令提示符,輸入python,然后在python環境下輸入import selenium,如果沒有提示錯誤,則安裝成功。

C:\Users\Ubuntu>python

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import selenium

>>>

下載瀏覽器驅動,本文以火狐為例,火狐的selenium驅動為geckodriver。geckodriver下載地址:geckodriver下載地址,下載解壓后,將geckodriver.exe文件放到python目錄下,本例地址為C:\Program Files\Python36,也可以將geckodriver.exe加入環境變量。

刷閱讀量腳本

實測在未登錄情況下,通過刷新頁面,可以達到增加閱讀量的效果,所以我們的策略是,打開瀏覽器,不停的刷新頁面,以達到增加閱讀量的效果。下面是刷數量代碼:

from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.support.ui import Select

from selenium.common.exceptions import NoSuchElementException

from selenium.common.exceptions import NoAlertPresentException

import unittest, time, re

class new_sub_count(unittest.TestCase):

def setUp(self):

self.driver = webdriver.Firefox()

self.driver.implicitly_wait(30)

self.base_url = 'https://www.jianshu.com/p/93a2895000d3' # 鏈接為需要刷數量的文章鏈接

self.verificationErrors = []

self.accept_next_alert = True

"""刷新閱讀量"""

def test_refresh_count(self):

driver = self.driver

driver.get(self.base_url)

for i in range(100): # 其中數字為要刷新的數量

time.sleep(2) # 為防止瀏覽器頻繁刷新僵死,故設置休息時間

driver.refresh() # 刷新

driver.quit() # 退出瀏覽器

if __name__ == '__main__':

unittest.main()

將上文的代碼保存為.py格式的文件,文件編碼為utf-8格式,本文將文件另存為count.py,并存儲在C:\Users\Ubuntu目錄下。

執行

打開命令提示符,進入存放文件的目錄,執行python count.py,如下:

C:\Users\Ubuntu>python

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> python count.py

執行開始后,程序會調用火狐瀏覽器,并自動進行刷新,以達到刷閱讀數量的效果。本文僅作技術交流,請正當使用~希望對大家的學習有所幫助,也希望大家多多支持我們。

本文標題: 通過python+selenium3實現瀏覽器刷簡書文章閱讀量

本文地址: http://www.cppcns.com/jiaoben/python/215698.html

總結

以上是生活随笔為你收集整理的python刷阅读_通过python+selenium3实现浏览器刷简书文章阅读量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。