title: How do I run command from web browser console in python?
body: <p>I have recently been trying to run a command through python in a web browser, as if using chrome developer tools.</p>
  <p><a href="https://i.stack.imgur.com/YD2hY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YD2hY.png" alt="" /></a></p>
  <p>This is easy to do from chrome, but how would I do it from python? I have no idea how I would go about replicating this from a python script. The browser command I am wanting to run is specific to the website I am working with, which is why I need to use the command line.</p>
  <p>How can I repsslicate running a command in the browser command line, in python 3? Sorry if this is a stupid question.
  Thanks!</p>
  <p>EDIT:
  I ended up using selenium, but ran into some problems. The site I am traveling to( roblox.com ), says that I am Unauthorized in the browser console.
  <a href="https://i.stack.imgur.com/ny0dI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ny0dI.png" alt="Picture2" /></a>
  I am pretty sure that I implemented the authentication cookies correctly though, as I am logged in. For some reason, some of my data just isn't loading, such as my currency count.</p>
  <p>This probably isn't the place to ask a question like this, since the members of this forum know nothing of roblox, but maybe it's a simple problem in my code.</p>
  <pre><code># my code
  from selenium import webdriver
  import time
  
  driver = webdriver.Chrome('C:\\Users\KDJ\Documents\GameJoiner\chromedriver.exe')
  options = webdriver.ChromeOptions()
  
  driver.execute_cdp_cmd('Network.setUserAgentOverride', {&quot;userAgent&quot;: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36'})
  driver.execute_script(&quot;Object.defineProperty(navigator, 'webdriver', {get: () =&gt; undefined})&quot;)
  options.add_experimental_option(&quot;excludeSwitches&quot;, [&quot;enable-automation&quot;])
  options.add_experimental_option('useAutomationExtension', False)
  
  
  URL = 'https://www.roblox.com/games'
  driver.get(URL)
  driver.add_cookie({'name' : '.ROBLOSECURITY', 'value' : Cookie})
  
  
  
  driver.get(URL)
  </code></pre>
  <p>As a side note, you might not see me defining the Cookie variable. This is because I removed it, since this cookie allows others to log into my account.</p>
  <p><a href="https://i.stack.imgur.com/Y0um4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y0um4.png" alt="enter image description here" /></a></p>