Python - Google Colab - Instalando o Brave
Python- Google Colab - Instalando o Brave | ||
Canal Qb |
!pip install brave-browser
from selenium import webdriveroptions = webdriver.ChromeOptions()options.binary_location = '/usr/bin/brave-browser'driver = webdriver.Chrome(options=options)
!pip install chromedriver-binary
--*--
Esse erro ocorre porque o pacote brave-browser não está disponível no repositório padrão do Python (PyPI). Uma possível solução é instalar o Brave manualmente no Colab. Para fazer isso, siga os seguintes passos:
Instale o pacote curl para baixar o instalador do Brave:
!apt install curl
Baixe o instalador do Brave:
!curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add -
!echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
!sudo apt update
!sudo apt install brave-browser
Importe o pacote webdriver do Selenium e configure as opções do Brave:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/brave-browser'
Crie uma instância do driver do Selenium para o Brave:
service = Service('/usr/lib/chromium-browser/chromedriver')
browser = webdriver.Chrome(service=service, options=options)
Com esses passos, você deve ser capaz de usar o Brave no Colab. Lembre-se de que o caminho do driver do Chrome (chromedriver) pode ser diferente no seu sistema, dependendo da versão do Brave que você instalou. Verifique se o caminho está correto antes de criar uma instância do driver.
!curl -sSL https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
!echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
!sudo apt-get update
!sudo apt-get install google-chrome-stable
!sudo apt-get install chromedriver
!apt-get update
!apt-get install -y chromium-browser
!apt-get install -yqq unzip
!curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /tmp/chrome.deb
!dpkg -i /tmp/chrome.deb
!apt-get install -yqq --no-install-recommends python3-selenium
!apt-get install -y chromium-chromedriver
Novo processo de instalação do Brave, descoberto hoje 19/10/2023
!apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8580BDC82D3DC6C
!echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
!apt-get update
!apt-get install brave-browser
Resultado:
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.jzn82uvO5S/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys A8580BDC82D3DC6C
gpg: key 0BB75829C2D4E821: 1 duplicate signature removed
gpg: key 0BB75829C2D4E821: "Brave Software <support@brave.com>" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main
Hit:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease
Get:2 https://brave-browser-apt-release.s3.brave.com stable InRelease [7,547 B]
Hit:3 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:6 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:8 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages [7,676 B]
Hit:9 https://ppa.launchpadcontent.net/c2d4u.team/c2d4u4.0+/ubuntu jammy InRelease
Hit:10 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease
Hit:11 https://ppa.launchpadcontent.net/graphics-drivers/ppa/ubuntu jammy InRelease
Hit:12 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy InRelease
Fetched 15.2 kB in 3s (5,767 B/s)
Reading package lists... Done
W: https://brave-browser-apt-release.s3.brave.com/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
brave-keyring libu2f-udev libvulkan1 mesa-vulkan-drivers
The following NEW packages will be installed:
brave-browser brave-keyring libu2f-udev libvulkan1 mesa-vulkan-drivers
0 upgraded, 5 newly installed, 0 to remove and 19 not upgraded.
Need to get 120 MB of archives.
After this operation, 396 MB of additional disk space will be used.
Get:1 https://brave-browser-apt-release.s3.brave.com stable/main amd64 brave-keyring all 1.16 [7,664 B]
Get:2 https://brave-browser-apt-release.s3.brave.com stable/main amd64 brave-browser amd64 1.59.120 [110 MB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libu2f-udev all 1.1.10-3build2 [4,190 B]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libvulkan1 amd64 1.3.204.1-2 [128 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 mesa-vulkan-drivers amd64 23.0.4-0ubuntu1~22.04.1 [9,521 kB]
Fetched 120 MB in 3s (44.2 MB/s)
Selecting previously unselected package libu2f-udev.
(Reading database ... 121343 files and directories currently installed.)
Preparing to unpack .../libu2f-udev_1.1.10-3build2_all.deb ...
Unpacking libu2f-udev (1.1.10-3build2) ...
Selecting previously unselected package libvulkan1:amd64.
Preparing to unpack .../libvulkan1_1.3.204.1-2_amd64.deb ...
Unpacking libvulkan1:amd64 (1.3.204.1-2) ...
Selecting previously unselected package brave-keyring.
Preparing to unpack .../brave-keyring_1.16_all.deb ...
Unpacking brave-keyring (1.16) ...
Selecting previously unselected package brave-browser.
Preparing to unpack .../brave-browser_1.59.120_amd64.deb ...
Unpacking brave-browser (1.59.120) ...
Selecting previously unselected package mesa-vulkan-drivers:amd64.
Preparing to unpack .../mesa-vulkan-drivers_23.0.4-0ubuntu1~22.04.1_amd64.deb ...
Unpacking mesa-vulkan-drivers:amd64 (23.0.4-0ubuntu1~22.04.1) ...
Setting up libu2f-udev (1.1.10-3build2) ...
Setting up brave-keyring (1.16) ...
Setting up libvulkan1:amd64 (1.3.204.1-2) ...
Setting up brave-browser (1.59.120) ...
update-alternatives: using /usr/bin/brave-browser-stable to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/brave-browser-stable to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
update-alternatives: using /usr/bin/brave-browser-stable to provide /usr/bin/brave-browser (brave-browser) in auto mode
Setting up mesa-vulkan-drivers:amd64 (23.0.4-0ubuntu1~22.04.1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc.so.2 is not a symbolic link
/sbin/ldconfig.real: /usr/local/lib/libtbbbind.so.3 is not a symbolic link
/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_5.so.3 is not a symbolic link
/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc_proxy.so.2 is not a symbolic link
/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_0.so.3 is not a symbolic link
/sbin/ldconfig.real: /usr/local/lib/libtbb.so.12 is not a symbolic link
Nenhum comentário
Comente só assim vamos crescer juntos!
Observação: somente um membro deste blog pode postar um comentário.