简体   繁体   中英

How can extract this information from web whatsapp; using python and selenium

Numbers from a group

Group

Hello to everyone i hope yall good. i want to extract these numbers from webwhatsapp using selenium

This is my code:

from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

import os

dir_path = os.getcwd()
profile = os.path.join(dir_path, "profile", "wpp")
s=Service('chromedriver.exe')
op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches', ['enable-logging'])
op.add_argument(
    r"user-data-dir={}".format(profile))


driver = webdriver.Chrome(service=s, options=op)

url='https://web.whatsapp.com'
driver.get(url)

numbers=driver.find_element(By.CLASS_NAME, "zzgSd _3e6xi").text
print(numbers)

But this dosnt work. Please help me!!

Right click on the element in inspect browser and copy selector pathCSS_选择器

And in selenium use numbers = driver.find_element_by_css_selector('#paste the path').text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM