Are sure you execute right Python interpreter,here at test an added
sys.executable
output.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import time, sys
#--| Setup
options = Options()
options.add_argument("--headless")
options.add_argument('--disable-gpu')
options.add_argument('--log-level=3')
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
browser.get('https://www.morningstar.com/stocks/XOSL/XXL/quote.html')
time.sleep(1)
soup = BeautifulSoup(browser.page_source, 'lxml')
bid_size = soup.select('div.dp-value.price-down.ng-binding.ng-scope')
price_sales = soup.select('li:nth-child(9) > div > div.dp-value.ng-binding')
print(price_sales[0].text.strip())
print(sys.executable)
Now have i comment out
#creationflags=CREATE_NO_WINDOW
Output:
C:\code\bs
λ python chrome_stock.py
DevTools listening on ws://127.0.0.1:62452/devtools/browser/c3c1f10a-9475-4bd7-97a0-418c7366b0d8
0.16
C:\python37\python.exe
As the path is
C:\python37
I will open file like this and remove comment and and save
service.py
.
C:\code\bs
λ vim C:\python37\Lib\site-packages\selenium\webdriver\common\service.py
Now run again,and there is no
DevTools listening
.
Output:
C:\code\bs
λ python chrome_stock.py
0.16
C:\python37\python.exe