I want to get the view count of a post in telegram. when I get the page source javaScript functions doesn’t executed yet and so the data is not enabled. any help?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import selenium.webdriver.support.expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Firefox()
driver.get("https://t.me/varzesh3/106369")
wait = WebDriverWait(driver, 30)
element = wait.until(EC.visibility_of_any_elements_located((By.CLASS_NAME,'tgme_widget_message_views')))
I even tried it with Chrome driver but no change.
2
Answers
There is a better Idea here. I can use bs4 with url https://t.me/varzesh3/106369?embed=1.
it's better because when you send the request by this url you have the iframe now.
and this is the code:
It’s not working because the element you want to check is inside an iframe. You need to first switch to IFrame.