I successfully created a python script that downloads stock data from the charting platform tradingview. When i start it from my local machine everything works fine.
Now i wanted to start the script from an ubuntu ec2 machine and a crontab. I first tried to run the script manually from the ec2 machine a couple days ago. Today i wanted to try to set up the crontab. It didnt work, so i tried to start the python script manually again. This time I get this error.
File "automated_prediction_ec2.py", line 282, in <module>
signin.click()
File "/home/ubuntu/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/ubuntu/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/ubuntu/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: headless chrome=86.0.4240.75)
First I thought it could be that tradingview changed their HTML, so I tried to run it from my local machine. This worked perfectly as before.
These are my ChromeOptions. I already tried several combinations to solve the problem but these are the ones where it worked last time.
options = webdriver.ChromeOptions()
prefs = {'download.default_directory' : '/home/ubuntu/daily_stock_data'}
options.add_argument('--headless')
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
options.add_experimental_option('prefs', prefs)
So what could be the problem, that one day my script is working from the ec2 machine and then suddenly i get this error? Furthermore the script is downloading 130 CSVs. Is there something like a download limit for a ec2 instance?
Here is the code where the error occurs.
driver.get("https://www.tradingview.com/")
driver.implicitly_wait(20)
signin = driver.find_element_by_class_name("tv-header__link.tv-header__link--signin.js-header__signin")
signin.click()
HTML Snippet of the page.
<span class="tv-header__dropdown-text">
<a class="tv-header__link tv-header__link--signin js-header__signin" href="#signin">Sign in</a>
</span>