Skip to content

Hard Code of the browser driver and there is no assurances in FireFox installation #2

@TsybulkaM

Description

@TsybulkaM

Fix issues

Hard Code of path to the browser driver:

geckodriver_path = '/snap/bin/geckodriver'

There is no assurances in FireFox installation:

driver = webdriver.Firefox(service=service, options=options)

Need to lib for dynamic using

pip install webdriver-manager

Sample usecase, if installed Google Chrome browser

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

Or FireFox

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

TODO task

Better parse data by BeautifulSoup tool + sample

pip install requests beautifulsoup4
import requests
from bs4 import BeautifulSoup

url = "http://example.com"
response = requests.get(url)

if response.status_code == 200:
    soup = BeautifulSoup(response.text, 'html.parser')

    title = soup.title.string
    print(f"Title of the page: {title}")

    links = soup.find_all('a')
    for link in links:
        print(link.get('href'))
else:
    print(f"Failed to retrieve page: {response.status_code}")

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions