In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use Python to achieve automatic reply to QQ messages". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Python to achieve automatic reply to QQ messages".
1. Preparation 1.1 install the client module
Open a command window and enter the command: pip install appium-python-client
1.2 install Appium Server
Download URL: http://appium.io
1.3 install JDK
After installation, add the environment variable JAVA_HOME, specify the installation directory of jdk, and edit as follows:
1.4 install android sdk
Add an environment variable ANDROID_HOME, set the value to the decompressed directory of the sdk package, and edit it as follows:
In addition, it is best to add the environment variable of adb.exe to path
1.5 screen casting software
The editor uses Mizhuo's on-screen assistant. The download URL is https://cn.mirroid.com.
two。 Connect to the mobile phone
The USB connection used by the editor requires a data cable to connect the phone with the computer, and the developer mode of the phone needs to be turned on.
So how to open developer mode, take the editor's phone as an example (OPPO phone) to come to the phone settings, click on the phone, and then always click on the version number, when the following words appear.
Then go to other settings (different phones may be different), and you can see that there is one more developer option here.
Go to the developer option, then open it, and you can find that there is a switch for USB debugging. Turn it on.
After opening it, you can see the screen of the mobile phone on the screen software.
3. Test whether the connection is successful
In the command window, enter: adb devices-l, if the following screen appears, it should be successfully connected!
At some point, there may be an error, generally due to the inconsistency between the adb.exe version of the screen software and the adb.exe version of sdk. (editor's own guess) you just need to copy any one of the adb.exe to the other one.
4. Code implementation
The reference code is as follows:
From appium import webdriver
Import time
Desired_caps= {
'platformName':'Android'
'platformVersion':'8.1'
'deviceName':'xxx'
'appPackage':'com.tencent.qqlite', # Automated applications
'appActivity':'com.tencent.mobileqq.activity.SplashActivity'
# 'unicodeKeyboard':True
# 'resetKeyboard':True
'noReset':True
'newCommandTimeout':6000
'automationName':'UiAutomator2'
}
Driver=webdriver.Remote ('http://localhost:4723/wd/hub',desired_caps)
Driver.implicitly_wait (10)
Driver2=driver.find_element_by_id ('recent_chat_list')
List2=driver2.find_elements_by_class_name ('android.widget.LinearLayout')
Print ('current QQ messages are d'% (len (list2)
Time.sleep (2)
List2 [0] .click ()
Def send_Message (text2:str): # send messages
Driver4=driver.find_element_by_id ('inputBar')
Driver4.find_element_by_id ('input'). Send_keys (text2)
Driver4.find_element_by_id ('fun_btn') .click ()
Time.sleep (2)
Print ("send message:% s"% (text2))
List4= [
"Liu Bang, Zi Ji, a native of Fengyi County, Pei County (now Fengxian County, Jiangsu Province). An outstanding statesman, strategist and military commander in Chinese history, the founding emperor of the Han Dynasty, the great founder and pioneer of the Han nationality and Han culture, made outstanding contributions to the development of the Han nationality and the reunification of China."
"not yet"
Hunan Province, referred to as "Xiang" for short, is a provincial administrative region of the people's Republic of China. Changsha, the capital of the province, is bounded by latitude 24 °38 °30 °08 north and longitude 108 °47 °15 'east, Jiangxi to the east, Chongqing and Guizhou to the west, Guangdong and Guangxi to the south and Hubei to the north, with a total area of 211800 square kilometers. "
]
While True:
Try:
Driver3=driver.find_element_by_id ('listView1')
List3=driver3.find_elements_by_class_name ('android.widget.RelativeLayout')
Text=list3 [- 1] .find _ element_by_id ('chat_item_content_layout') .text
Print ('received message:% received% (text)) # received message
Time.sleep (5)
If (Hello text==', please check Liu Bang's profile for me'):
Send_Message (list4 [0])
Elif (text== "have you had lunch yet"):
Send_Message (list4 [1])
Elif (text== "introduce Hunan!") :
Send_Message (list4 [2])
Except Exception as e:
Pass
In the process of running the code, something will be automatically installed on the phone. Just agree to install it.
Thank you for your reading, the above is the content of "how to use Python to achieve automatic reply to QQ messages". After the study of this article, I believe you have a deeper understanding of how to use Python to achieve automatic reply to QQ messages, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.