0

I'm trying to find some elements on https://instagram.com using Selenium and my code works on my computer, but when I run it on PythonAnywhere and try to find at least body it returns " ". Code:

from selenium import webdriver

def code():
    browser = webdriver.Firefox()
    browser.get('https://instagram.com')
    print(browser.find_element_by_tag_name('body').text)

def main():
    code()

if __name__ == '__main__':
    main()

I tried to test it with some random web-sites from their Whitelist and it Worked! But Instagram is also there... So, I am a little bit confused. What's my mistake? Any help is appreciated.

5
  • 'https://.instagram.com' is a bit weird -- shouldn't it be 'https://instagram.com' without the extra dot? Commented Nov 4, 2015 at 19:34
  • @GilesThomas yep, it's without extra dot, I misspelled it. But it doesn't solve the problem Commented Nov 4, 2015 at 19:44
  • If it runs without logging into instagram, there may not be much/any text there. Have you tried logging in and then checking BODY? Commented Nov 4, 2015 at 20:10
  • @JeffC I tried to do that but it couldn't find the forms(username and password fields) so someone advised me to try to print out body to check if my code even opens up the site Commented Nov 5, 2015 at 5:24
  • what if you print browser.page_source? Commented Nov 9, 2015 at 11:54

1 Answer 1

1

We have not whitelisted the top-level instagram domain (instagram.com) only the subdomains (like api.instagram.com etc.) so you cannot scrape instagram using selenium. You can, however, use the API since that is the preferred way of accessing instagram from software.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.