I am currently trying to use Ruby’s Selenium to retrieve the view counts of Instagram Reels.
However, the view count numbers are not being rendered, and the target HTML elements are not present in the DOM obtained through Selenium.
When I view the Reels page of the target user in a normal browser, the view counts are displayed correctly.
Why is this happening?
Note: The square garbled text at the top of the Selenium images is due to missing fonts.
This is my selenium settings in docker.
options = Selenium::WebDriver::Chrome::Options.new
# for using selenium in docker
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36')
options.add_argument('--window-size=1920,1080')
@driver = Selenium::WebDriver.for(:chrome, options:)