Python Forum
ZetCode selenium tutorial - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: ZetCode selenium tutorial (/thread-24369.html)



ZetCode selenium tutorial - Larz60+ - Feb-11-2020

Zetcode has just released a selenium tutorial here: http://zetcode.com/python/selenium/
I haven't reviewed it, so just an FYI


RE: ZetCode selenium tutorial - wavic - Feb-11-2020

I used PhantomJS today and when I ran the script for the first time a Selenium´s message appeared and it said that PhantomJS is deprecated. Quick googling and it turned out that it´s no longer in development. Lack of contributors to the project. Very sad. Now we have to use chromedriver. I prefer to avoid Google in every way.


RE: ZetCode selenium tutorial - Larz60+ - Feb-11-2020

found this, haven't investigated: https://www.slant.co/options/2764/alternatives/~phantomjs-alternatives


RE: ZetCode selenium tutorial - wavic - Feb-11-2020

Hm! I see that Puppeteer is a Node library provided by Google to control Chrome.
So, Google again.


RE: ZetCode selenium tutorial - snippsat - Feb-12-2020

They use a Deprecated method with opts.headless = True.
This will give a warning when use it.
opts = Options()
opts.headless = True
Otherwise it look okay,and fine that they show example with pytest and Flask.

To show a example how option should be used now.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import time

#--| Setup
options = Options()
options.add_argument("--headless")
options.add_argument('--disable-gpu')
options.add_argument('--log-level=3')
browser = webdriver.Chrome(executable_path=r'chromedriver', 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')
price_sales = soup.select('li:nth-child(9) > div > div.dp-value.ng-binding')
print(price_sales[0].text.strip())
wavic Wrote:I used PhantomJS today and when I ran the script for the first time a Selenium´s message appeared and it said that PhantomJS is deprecated
It's couple of years now that PhantomJS has been out of the picture,since Chrome and Firefox makes own driver for this now.