I'm having difficulty fetching the complete conversation data for a contact using Google Messages. Currently, I can only fetch the first message of each contact, but I cannot retrieve the entire conversation. Not sure if i am picking the wrong class... idk tbh please help
from selenium import webdriver
from selenium.webdrivermon.by import By
import time
driver = webdriver.Chrome()
driver.get('')
print("Please log in to Google Messages on your PC.")
time.sleep(30) # Adjust time to give you time to log in manually
contact_name = "AX-ARTLTV"
try:
contact = driver.find_element(By.XPATH, f"//span[text()='{contact_name}']")
contact.click()
print(f"Opening conversation with {contact_name}...")
except Exception as e:
print(f"Error: {e}")
driver.quit()
time.sleep(5)
for _ in range(10): # Adjust the range for more/less scrolling
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2) # Wait for messages to load after scrolling
messages = driver.find_elements(By.CLASS_NAME, 'ng-star-inserted')
print("\nMessages:")
for msg in messages:
print(msg.text)
driver.quit()
So in my code i want to fetch all the messages from AX-ARTLTV but... not workin ;-;