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}")
Fix issues
Hard Code of path to the browser driver:
LogicWaySolution/myproject/scraper/scraper.py
Line 9 in 3be4114
There is no assurances in FireFox installation:
LogicWaySolution/myproject/scraper/scraper.py
Line 22 in 3be4114
Need to lib for dynamic using
Sample usecase, if installed Google Chrome browser
Or FireFox
TODO task
Better parse data by BeautifulSoup tool + sample