0

I'm trying to connect to Tradingview with cookie using selenium and python

  1. I have the cookie in my folder.... ok

  2. Now i am trying to load the cookie and connect with it ... without result :(

any help is welcome.

thank you

here the code to load the cookie

        # Create WebDriverWait
        self.wait = WebDriverWait(self.driver, 20)
        
        self.driver.get("https://www.tradingview.com")

        with open('cookies.pkl', 'rb') as f:
            cookies = pickle.load(f)

        for cookie in cookies:
            cookie['domain'] = ".tradingview.com"
            try:
                self.driver.add_cookie(cookie)
            except Exception as e:
                print(e)

        #self.driver.refresh()
        self.driver.get('https://www.tradingview.com/')

        time.sleep(30)
Nuno
  • 1
  • 2

1 Answers1

0

try this:

driver.get(f'https://www.tradingview.com/chart/{my chart}')


# Retrieve cookies containing info and refresh the page
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
    driver.add_cookie(cookie)
driver.refresh()

see: How to save and load cookies using Python + Selenium WebDriver

n0x
  • 9
  • 5