SoFunction
Updated on 2025-03-01

Python3 selenium implements QQ group spindle automation function

1. Environment

The environment is configured to have Python3 installed with selenium module and the corresponding driver of the browser
If selenium is not installed, you can execute the following code in the console

pip3 install selenium

Browser driver download address:/#drivers
You need to select the corresponding version of the corresponding browser to download it
After the download is completed, put it in the Python installation directory.

2. Code

Disadvantages: Only automatic serialization can be performed for the latest released group of serialization

from selenium import webdriver
import time
import datetime

QQ = "Fill in the QQ number here"
password = "Fill in QQ password here"
qun = "Fill in the QQ group number that requires a serial number here"

browser = ()
# If it is another browser, please refer to the document directly, for example, Google Chrome is ()("/") # Log in to QQ through QQ spacebrowser.switch_to.frame("login_frame") # Switch to the login window in the web pagebrowser.find_element_by_id("switcher_plogin").click()
(1)
# Clear the contents in the account box and password box firstbrowser.find_element_by_id('u').clear()
browser.find_element_by_id('p').clear()
(1)
# Automatically enter QQ number and passwordbrowser.find_element_by_id("u").send_keys(QQ)
browser.find_element_by_id("p").send_keys(password)
(1)
browser.find_element_by_id("login_button").click() # Click the login buttonbrowser.switch_to.default_content() # Switch back to the main pageurl = "/homework/qunsolitaire/?_wv=1031&gc=" + qun + "&from=appstore_icon&from=qqminiprogram=" + qun + "&state=1"
# Write the check-in web page into the variable urlprint(url)
print("If the login is successful and does not automatically jump to the group collar page, please visit the URL")
print("/")
print("Add your QQ number at the end of the above address")
while True: # Determine whether the login is successful  (1) # Prevent the computer from being stuck due to too fast judgment, and you can adjust it yourself  if browser.current_url == "/"+QQ:
    print('Login successfully!  ')
    break
while True:
  (url)
  (0.5) # Prevent the computer from being stuck due to too fast judgment, and you can adjust it yourself  str = browser.find_element_by_xpath("/html/body/div/div[1]/div[1]/div[3]").text
  # Determine whether the first solitaire has been completed  if str == "Solidden" or str == "Ended":
    (1)
    continue
  browser.find_element_by_xpath("/html/body/div/div[1]/div[1]/div[3]").click()
  (0.5)
  browser.find_element_by_xpath("/html/body/div/div[2]/div/div[2]").click()
  print(().strftime('%Y%m%d %H%M%S Group Solidar sign-in successfully'))
  (1)

Summarize

This is the article about Python3 selenium implementing the QQ group automation function. For more related content on Python selenium, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!