主要是给我的投币器做个铺垫,果然软件还是太容易了,难在硬件和外壳好吗!
1 把edge的调试端口打开:
添加以下参数:
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --remote-debugging-port=9225 --user-data-dir="C:\Users\10913\AppData\Local\Microsoft\Edge\User Data\Default"
2 装EDGE的驱动,这个轻车熟路不说了,目前我用的SELEIUM3 据说4变化比较大 先不用
3 py脚本在此
from msedge.selenium_tools import Edge, EdgeOptions # pip install msedge-selenium-tools
from selenium.webdriver.common.by import By
import time
edge_options = EdgeOptions()
edge_options.use_chromium = True
edge_options.add_argument("disable-gpu")
edge_options.add_experimental_option("debuggerAddress", "127.0.0.1:9225")
driver = Edge(options=edge_options)
nowpage=driver.current_url
if 'https://www.bilibili.com/video' in nowpage:
print('在看BILIBILI视频')
buttons = driver.find_element(by=By.CLASS_NAME,value="coin")
#print(buttons)
buttons.click()
time.sleep(0.5)
try:
sure = driver.find_element(by=By.CLASS_NAME,value="bi-btn")
#coin2 = driver.find_element(by=By.CLASS_NAME,value="mc-box right-con")
print(sure)
sure.click()
except:
print('已投币')
else:
print('当前非BILIBILI页面')
其实可以不用傻傻每次都让浏览器从seleium启动的,直接接手多好,对于一些爬虫验证可太好用了,人工通过验证,然后程序接管,美滋滋。