So i can scrape instagram hashtag posts count with the code below.
from selenium import webdriver
driver = webdriver.Firefox()
ig_link = 'https://www.instagram.com/explore/tags/100x35/'
driver.get(ig_link)
# Scrape Posts Count
posts_count = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/header/div[2]/div[1]/div[2]/span/span').text
print(posts_count)
driver.close()
The problem I have is when a hash tag has a flag in it for example:
https://www.instagram.com/explore/tags/100x35????????/
from selenium import webdriver
driver = webdriver.Chrome()
ig_link = 'https://www.instagram.com/explore/tags/100x35????????/'
driver.get(ig_link)
# Scrape Posts Count
posts_count = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/header/div[2]/div[1]/div[2]/span/span').text
print(posts_count)
driver.close()
I get the following error:
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//[@id="react-root"]/section/main/header/div[2]/div[1]/div[2]/span/span"}*