代码拉取完成,页面将自动刷新
#! /usr/bin/python3
'''
Author- Tony Stark
download https://github.com/mozilla/geckodriver/releases
set path paste binary file /usr/local/bin
install requirements: pip3 install selenium
'''
from selenium import webdriver
import os
import time
driver = webdriver.Firefox()
driver.get("http://web.whatsapp.com")
name=input("Please Enter Name for search online status: ")
while True:
try:
chat=driver.find_element_by_xpath("/html/body/div[1]/div/div/div[3]/div/header/div[2]/div/span/div[2]/div")
chat.click()
time.sleep(2)
search=driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div[1]/span/div/span/div/div[1]/div/label/input")
search.click()
time.sleep(2)
search.send_keys(name)
time.sleep(2)
open=driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div[1]/span/div/span/div/div[2]/div[1]/div/div/div[2]/div/div")
open.click()
time.sleep(2)
while True:
try:
status = driver.find_element_by_class_name("_315-i").text
name = driver.find_element_by_class_name("_19vo_").text
print("{0} is {1}".format(name,status))
time.sleep(30)
except:
name = driver.find_element_by_class_name("_19vo_").text
print("{0} is {1}".format(name,"offline"))
time.sleep(30)
except:
pass
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。