1)from selenium import webdriver
from selenium.webdriver.common.by import By
Start a new browser session
driver = webdriver.Chrome()
try:
# Open the Instagram page
driver.get("https://www.instagram.com/guviofficial/")
# Wait for the page to load
driver.implicitly_wait(10) # Wait for 10 seconds for elements to appear
# Extract the number of posts
post_count_element = driver.find_element(By.XPATH, '//span[text()="posts"]/span')
post_count = post_count_element.text
print("Number of posts:", post_count)
# Extract the number of followers
follower_count_element = driver.find_element(By.XPATH, '//span[@title="Followers"]/span')
follower_count = follower_count_element.get_attribute("title")
print("Number of followers:", follower_count)
# Extract the number of following
following_count_element = driver.find_element(By.XPATH, '//span[@title="Following"]/span')
following_count = following_count_element.get_attribute("title")
print("Number of following:", following_count)
finally:
# Close the browser
driver.quit()
2) from selenium import webdriver
from selenium.webdriver.common.by import By
Start a new browser session
driver = webdriver.Chrome()
try:
# Open the Instagram profile page
driver.get("https://www.instagram.com/guviofficial/")
# Wait for the page to load
driver.implicitly_wait(10) # Wait for 10 seconds for elements to appear
# Extract the number of followers
followers_element = driver.find_element(By.XPATH, '//a[@href="/guviofficial/followers/"]/span')
followers_count = followers_element.get_attribute("title")
print("Followers:", followers_count)
# Extract the number of following
following_element = driver.find_element(By.XPATH, '//a[@href="/guviofficial/following/"]/span')
following_count = following_element.get_attribute("title")
print("Following:", following_count)
finally:
# Close the browser
driver.quit()
Top comments (0)