selenium模擬瀏覽器操作

def bitalk_log(username,password):
    # 請求登錄頁面
    try:
        drive = webdriver.Chrome()
        url = 'https://steemconnect.com/oauth2/authorize?client_id=duozhuan&redirect_uri=https%3A%2F%2Fwww.bitalk.cc%2Fcallback%2F&scope='
        drive.get(url)
        # 睡眠2秒
        time.sleep(2)
        # 找到continue按鈕點擊進去
        drive.find_element_by_xpath("http://button").click()
        # 休眠0.5秒鐘后執(zhí)行填寫用戶名和密碼操作
        time.sleep(0.5)
        # 找到用戶名輸入用戶名
        user = drive.find_element_by_id("username")
        user.send_keys(username)
        # 找到密碼輸入密碼
        drive.find_element_by_id("password").send_keys(password)
        # 點擊登錄按鈕實現(xiàn)登錄
        drive.find_element_by_xpath("http://button").click()
        # 登錄成功后跳轉(zhuǎn)首頁,進行加載,休眠10秒加載頁面
        time.sleep(20)
        # 點擊進入發(fā)帖頁面
        return drive
    except Exception as e:
        print("出現(xiàn)問題",e)
# 實現(xiàn)發(fā)帖
def fatie(drive,json):
            # 獲取內(nèi)容
            title1 = drive.find_element_by_xpath("http://div[@class='StoryFull']/h1[@class='StoryFull__title']").text
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容