最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python自動(dòng)掃描出微信不是好友名單的方法

 更新時(shí)間:2021年05月20日 08:43:06   作者:Huny  
很多人想要清楚已經(jīng)被刪除的好友名單。面對(duì)龐大的好友數(shù)量想要清除談何容易,本文主要介紹了Python自動(dòng)掃描出微信不是好友名單的方法,感興趣的可以了解一下

前言

最近找?guī)讉€(gè)老友準(zhǔn)備聊天發(fā)現(xiàn)幾個(gè)已經(jīng)被刪除好友名單,做為潛水黨多年的我已經(jīng)不知道成為多少人的黑名單,但是好友列表卻依然有不是好友的名單,面對(duì)龐大的好友數(shù)量想要清除談何容易。雖然可以發(fā)消息給所有人,來(lái)識(shí)別是否是好友,但是畢竟打擾到了其他人,經(jīng)過(guò)一番查詢發(fā)現(xiàn)點(diǎn)擊轉(zhuǎn)賬時(shí)會(huì)提示不是好友,這里只是點(diǎn)擊轉(zhuǎn)賬并不是真的轉(zhuǎn)賬哦。做為一名技術(shù)潛水黨,肯定要低調(diào)的辦好事情。之前已經(jīng)用appium玩過(guò)自動(dòng)化了,那么這次就輕車(chē)熟路了。

準(zhǔn)備

1.Appium環(huán)境搭建
環(huán)境搭建這里不再介紹,需要的可以看我之前的文章或者百度
2.手動(dòng)操作流程圖轉(zhuǎn)自動(dòng)操作流程圖


最開(kāi)始畫(huà)的流程圖,然后按照流程圖去實(shí)現(xiàn)操作流程和邏輯。初步實(shí)現(xiàn)完成后進(jìn)行調(diào)試,過(guò)程中不少邏輯不嚴(yán)謹(jǐn)?shù)牡胤?,以及一些框架自帶的坑,最終總算可以一次性掃描了。但是其中還是存在個(gè)別的坑需要手動(dòng)處理一下。暫時(shí)先記錄下來(lái),等以后看情況優(yōu)化吧。
遇到暫?;臼橇奶齑白R(shí)別不到了,可以手動(dòng)上滑一下,讓程序識(shí)別下一個(gè)聊天窗口。需要先登陸微信號(hào)。

代碼

from appium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from selenium.common.exceptions import StaleElementReferenceException

# platformVersion = input('系統(tǒng)版本號(hào)(platformVersion): ')
# deviceName = input('設(shè)備名稱(deviceName):')


desired_caps = {
    "platformName": "Android",  # 系統(tǒng)
    "platformVersion": '10.0',  # 系統(tǒng)版本號(hào)
    # "platformVersion": platformVersion,  # 系統(tǒng)版本號(hào)
    "deviceName": 'b68548ed',  # 設(shè)備名
    # "deviceName": deviceName,  # 設(shè)備名
    "appPackage": "com.tencent.mm",  # 包名
    "appActivity": ".ui.LauncherUI",  # app 啟動(dòng)時(shí)主 Activity
    'unicodeKeyboard': True,  # 使用自帶輸入法
    'noReset': True  # 保留 session 信息,可以避免重新登錄
}


def is_element_exist(driver, by, value):
    """判斷元素是否存在"""
    try:
        driver.find_element(by=by, value=value)
    except Exception as e:
        return False
    else:
        return True


def break_key(n):
    """點(diǎn)擊返回按鈕"""
    for i in range(n):
        el1 =  wait.until(EC.element_to_be_clickable((By.ACCESSIBILITY_ID,"返回")))
        el1.click()

def swipe_up():
    """向上滑動(dòng)屏幕"""
    # 獲取屏幕的size
    size = driver.get_window_size()
    # 獲取屏幕寬度 width
    width = size['width']
    # 獲取屏幕高度 height
    height = size['height']
    x1 = width*0.5
    y1 = height*0.45
    y2 = height*0.3
    driver.swipe(x1,y1,x1,y2,3000)
    print("向上滑動(dòng)")
    

if __name__ == '__main__':
    driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
    # 設(shè)置等待
    wait = WebDriverWait(driver, 300)
    status = True
    n = 2
    count = 1   
    while status:
        try:
            # 點(diǎn)擊通訊錄
            a1 = wait.until(EC.element_to_be_clickable(
                (By.XPATH, "http://android.widget.FrameLayout[@content-desc=\"當(dāng)前所在頁(yè)面,與的聊天\"]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.RelativeLayout[2]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.ImageView")))
            a1.click()
            #向上滑動(dòng)
            swipe_up()
            if n < 13:
                # 進(jìn)入第一個(gè)聊天窗口,公眾號(hào)為1,用戶元素定位從2開(kāi)始,一頁(yè)最多12,每滑動(dòng)屏幕從新開(kāi)始到12.
                g73 = wait.until(EC.element_to_be_clickable(
                    (By.XPATH, "http://android.widget.FrameLayout[@content-desc='當(dāng)前所在頁(yè)面,與的聊天']/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/com.tencent.mm.ui.mogic.WxViewPager/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[%d]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.view.View"%(n))))
                g73.click()
                print("進(jìn)入了第%d個(gè)好友聊天窗口"%(count))
                count += 1
            else:
                n -= 1
                g73 = wait.until(EC.element_to_be_clickable(
                    (By.XPATH, "http://android.widget.FrameLayout[@content-desc='當(dāng)前所在頁(yè)面,與的聊天']/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.FrameLayout/com.tencent.mm.ui.mogic.WxViewPager/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.LinearLayout[%d]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.view.View"%(n))))
                g73.click()
                print("進(jìn)入了第%d個(gè)好友聊天窗口"%(count))
                count += 1
            # 判斷聊天窗是否有發(fā)送消息的元素
            is_weichat = is_element_exist(driver, "id", "com.tencent.mm:id/ijq")
            if is_weichat == True:
                while True:
            #     # 有發(fā)消息則點(diǎn)擊
                    wait.until(EC.element_to_be_clickable(
                    (By.ID, "com.tencent.mm:id/ijq"))).click()
                    print("點(diǎn)擊了發(fā)消息")
                    #點(diǎn)擊+號(hào)
                    is_jia = is_element_exist(driver, 'id', 'com.tencent.mm:id/ay7')
                    #判斷是否有加號(hào)
                    if is_jia == True:
                        el4 = wait.until(EC.element_to_be_clickable((By.ID, "com.tencent.mm:id/ay7")))
                        el4.click()
                        print('點(diǎn)擊+號(hào)')
                        #判斷是否為轉(zhuǎn)賬
                        is_zhuanzhang = wait.until(EC.element_to_be_clickable((By.XPATH,"http://android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.GridView/android.widget.LinearLayout[6]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView")))
                        if is_zhuanzhang.text == "轉(zhuǎn)賬":
                        # is_zhuanzhang = is_element_exist(driver, 'xpath', '//android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.GridView/android.widget.LinearLayout[6]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView')
                        # if is_zhuanzhang == True:
                            #點(diǎn)擊轉(zhuǎn)賬
                            el5 =  wait.until(EC.element_to_be_clickable((By.XPATH,"http://android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.GridView/android.widget.LinearLayout[6]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.ImageView[2]")))
                            el5.click()
                            print('點(diǎn)擊轉(zhuǎn)賬')
                            #輸入金額0.01
                            el6 = wait.until(EC.element_to_be_clickable((By.ID,"com.tencent.mm:id/jf4")))
                            el6.send_keys("0.01")
                            print('輸入金額')
                            #點(diǎn)擊確認(rèn)轉(zhuǎn)賬
                            el7 =  wait.until(EC.element_to_be_clickable((By.ID,"com.tencent.mm:id/e6c")))
                            el7.click()
                            print('點(diǎn)擊確認(rèn)轉(zhuǎn)賬')
                            time.sleep(2)
                            #判斷是否有知道了
                            is_not_friend = is_element_exist(driver,'id','com.tencent.mm:id/ffp')
                            if is_not_friend == True:
                            #點(diǎn)擊知道了
                                el8 =  wait.until(EC.element_to_be_clickable((By.ID,"com.tencent.mm:id/ffp")))
                                el8.click()
                                print('點(diǎn)擊知道了')
                                #獲取用戶名稱并打印
                                el9 =  wait.until(EC.element_to_be_clickable((By.ID,"com.tencent.mm:id/h2k")))
                                print('不是好友的微信名稱為:',el9.text)
                                with open('weixin.txt','a+')as f:
                                    f.write('不是好友的微信名稱:' + el9.text + '\n')
                                driver.keyevent(4)
                                driver.keyevent(4)
                                driver.keyevent(4)
                                driver.keyevent(4)
                                print('返回')
                                n += 1                
                                break
                            else:
                                #沒(méi)有知道則返回
                                driver.keyevent(4)
                                break_key(2)
                                n += 1
                                print('返回')
                                break
                        else:
                            #沒(méi)有轉(zhuǎn)賬則返回到首頁(yè)
                            driver.keyevent(4)
                            driver.keyevent(4) 
                            print('返回')
                            n += 1
                            break

                    else:
                        #沒(méi)有+號(hào)則返回到首頁(yè)
                        driver.keyevent(4)
                        driver.keyevent(4)
                        print('返回')
                        n += 1
                        break
        except StaleElementReferenceException:
            print('捕獲StaleElementReferenceException異常')                    

這里已經(jīng)掃描到200多個(gè)好友了,其中可能需要手動(dòng)上滑一下


不是好友的名單會(huì)在當(dāng)前目錄生成一個(gè)txt文件進(jìn)行保存


偶然出現(xiàn)幾個(gè)異常,不知道是什么原因


總的來(lái)說(shuō)功能基本都已經(jīng)實(shí)現(xiàn)了,還有細(xì)節(jié)問(wèn)題后面看情況優(yōu)化吧

到此這篇關(guān)于Python自動(dòng)掃描出微信不是好友名單的方法的文章就介紹到這了,更多相關(guān)Python自動(dòng)掃描出微信好友內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 基于Python實(shí)現(xiàn)一個(gè)自動(dòng)關(guān)機(jī)程序并打包成exe文件

    基于Python實(shí)現(xiàn)一個(gè)自動(dòng)關(guān)機(jī)程序并打包成exe文件

    這篇文章主要介紹了通過(guò)Python創(chuàng)建一個(gè)可以自動(dòng)關(guān)機(jī)的小程序,并打包成exe文件。文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Python有一定的幫助,感興趣的同學(xué)可以了解一下
    2021-12-12
  • python繪制直線的方法

    python繪制直線的方法

    這篇文章主要為大家詳細(xì)介紹了python繪制直線的方法,繪制直線通用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • python區(qū)塊鏈簡(jiǎn)易版交易完善挖礦獎(jiǎng)勵(lì)示例

    python區(qū)塊鏈簡(jiǎn)易版交易完善挖礦獎(jiǎng)勵(lì)示例

    這篇文章主要介紹了python區(qū)塊鏈簡(jiǎn)易版交易完善挖礦獎(jiǎng)勵(lì)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • python中對(duì)列表的刪除和添加方法詳解

    python中對(duì)列表的刪除和添加方法詳解

    這篇文章主要為大家詳細(xì)介紹了python中對(duì)列表的刪除和添加方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-02-02
  • 詳解python中的 is 操作符

    詳解python中的 is 操作符

    is 操作符是Python語(yǔ)言的一個(gè)內(nèi)建的操作符。它的作用在于比較兩個(gè)變量是否指向了同一個(gè)對(duì)象。下面通過(guò)本文給大家詳細(xì)介紹python中的 is 操作符,需要的朋友參考下吧
    2017-12-12
  • pandas 按照特定順序輸出的實(shí)現(xiàn)代碼

    pandas 按照特定順序輸出的實(shí)現(xiàn)代碼

    這篇文章主要介紹了pandas 按照特定順序輸出的實(shí)現(xiàn)代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-07-07
  • Python?類(lèi)中定義多個(gè)構(gòu)造器方法重載與泛方法

    Python?類(lèi)中定義多個(gè)構(gòu)造器方法重載與泛方法

    這篇文章主要為大家介紹了Python?類(lèi)中定義多個(gè)構(gòu)造器方法重載與泛方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • 在pyCharm中下載第三方庫(kù)的方法

    在pyCharm中下載第三方庫(kù)的方法

    這篇文章主要介紹了在pyCharm中下載第三方庫(kù)的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-04-04
  • tensorflow學(xué)習(xí)筆記之tfrecord文件的生成與讀取

    tensorflow學(xué)習(xí)筆記之tfrecord文件的生成與讀取

    這篇文章主要介紹了tensorflow學(xué)習(xí)筆記之tfrecord文件的生成與讀取,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • python繪圖庫(kù)Matplotlib的安裝

    python繪圖庫(kù)Matplotlib的安裝

    這篇文章主要介紹了python庫(kù)繪圖Matplotlib的安裝,需要的朋友可以參考下
    2014-07-07

最新評(píng)論

平阳县| 新宁县| 铁岭市| 庄河市| 高青县| 锦屏县| 柏乡县| 台中市| 环江| 台中县| 明水县| 新余市| 施秉县| 清新县| 南雄市| 西峡县| 苗栗县| 札达县| 玉屏| 叙永县| 林州市| 牡丹江市| 武义县| 昌邑市| 新巴尔虎左旗| 萍乡市| 徐水县| 陇南市| 广宁县| 河东区| 温宿县| 石台县| 巨鹿县| 太康县| 界首市| 筠连县| 马鞍山市| 祁连县| 香港| 蒲城县| 德安县|