|
先到網站拿原始碼並修改
- from selenium import webdriver
- import random
- import time
- options = webdriver.ChromeOptions()
- # 禁用瀏覽器彈窗避免預設路徑載入失敗
- prefs = {
- 'profile.default_content_setting_values':
- {
- 'notifications': 2
- }
- }
- # 找到Google擴充套件的檔案位置(注意路徑需使用雙斜線 "\")
- options.add_extension(
- 'C:\\Users\\Administrator\\CRX-Emulator-Chrome.crx')
- # 將擴充套件放入至Webdriver的開啟網頁內容
- options.add_experimental_option('prefs', prefs)
- # 隱藏『Chrome正在受到自動軟體的控制』這項資訊
- options.add_argument("disable-infobars")
- # 啟動selenium 務必確認driver 檔案跟python 檔案要在同個資料夾中
- driver = webdriver.Chrome(options=options)
- # 啟動擴充套件連上VPN
- # 連結套件的html位置 chrome-extension://panel/panel.html
- driver.get("chrome-extension://panel/panel.html")
- # 進入迴圈設定點擊次數、點擊目標、間斷時間
- # 設定點擊次數
- times = 5
- # 設定目標網址
- url = "https://www.netyea.com/"
- for i in range(1, times + 1):
- # 設定隨機間隔時間避免短時間大量造訪被拒
- rest = random.randint(1, 10)
- # 嘗試以VPN進入網站刷點擊率
- try:
- # 透過find_element_by_xpath找到點擊的位置並且點擊
- driver.find_element_by_xpath('//*[@id="screenMain"]/div[3]/div[1]').click()
- # 進入目標網頁
- driver.get(url)
- # 等待載入
- time.sleep(2)
- print("Success times:" + str(i) + "/" + str(times))
- # 回到外部套件關閉VPN
- driver.get("chrome-extension://panel/panel.html")
- driver.find_element_by_xpath('//*[@id="screenMain"]/div[3]/div[1]').click()
- time.sleep(rest)
- except:
- print("Error! You need to check the website or code and restart the program!")
- break
- print("Mission Complete!!")
- driver.close()
複製代碼
到CRX Emulator 下載插件
python selenium 洗網站流量
python selenium 洗網站流量
下載後把檔案修改成CRX-Emulator-Chrome.crx 並放入路徑 C:\\Users\\Administrator
測試了之後出現訊息
Error! You need to check the website or code and restart the program!
Mission Complete!!
發現是VPN那段有問題
# 啟動擴充套件連上VPN
# 連結套件的html位置 chrome-extension://panel/panel.html
driver.get("chrome-extension://panel/panel.html")
這段還不知如何處理
測試修改後在PO上
|
|