python+selenium h5新浪微博自動點贊

同樣採用h5版頁面進行自動化點贊
update:微博會莫名其妙取消掉點過的贊圖標,但是讚的內容還在,沒辦法先取消了,只點別人沒點過讚的微博

#sina weibo like robot
import time
from selenium import  webdriver

weiboUrl='https://passport.weibo.cn/signin/login?entry=mweibo&res=wel&wm=3349&r=https%3A%2F%2Fm.weibo.cn%2F'
user=''
password=''
chromeDriverPath='/Users/vanues/Downloads/chromedriver'#在這裏修改你的driver路徑

driver=webdriver.Chrome(chromeDriverPath)
driver.get(weiboUrl)
time.sleep(5)
driver.find_element_by_id('loginName').clear()
driver.find_element_by_id('loginName').send_keys(user)
driver.find_element_by_id('loginPassword').clear()
driver.find_element_by_id('loginPassword').send_keys(password)
driver.find_element_by_id('loginAction').click()
time.sleep(4)
#print("test1")
driver.find_element_by_xpath('//*[@id="app"]/div[1]/div[1]/div[2]/div/div[1]/div[1]/div/ul/li[1]/span[1]').click()#這句用來打開關注的分組(首頁全點需要刪除這句和後面這句)
#print('test2')
driver.find_element_by_xpath('//*[@id="app"]/div[1]/div[1]/div[2]/div/div[1]/div[2]/ul/li[8]/span').click()#這句用來打開我目前選定的一個分組(自己使用需要修改)
time.sleep(5)
while 1:
    i = 1
    while i <= 10:
        btn = driver.find_element_by_xpath('//*[@id="app"]/div[1]/div[2]/div[2]/div['+str(i)+']/div/div/footer/div[3]')
        i += 1
        if btn.text == '贊':
            time.sleep(5)
            btn.click()
            print("liked")
        else:
            break
    print("going to refresh in 60s")
    driver.refresh()
    time.sleep(60)

#while 1:
    #time.sleep(5)
    #btns=driver.find_elements_by_class_name('lite-iconf-like')
    #for btn in btns:
        #time.sleep(5)
        #print("btn:" + str(btn.text)+"\tid:"+str(btn.id))
        #btn.click()
    #driver.refresh()
    #time.sleep(60)

QQ空間自動點贊可見:空間點贊器

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章