Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Python Selenium | Chromium | Raspberry Pi | How to use Proxy settings of Tor

Hey Guys,

im trying to use Python Selenium on my Raspberry pi but with the proxy settings of the Tor service. But what ever i try it doesn load the page:
i mean chromium is starting but it loads until it stops because respond takes to long. i dont know what the problem is.

what i have done:

file /etc/privoxy/config ->

l
Code
isten-address  localhost:8118
listen-address  192.168.1.105:8118

and

Code
forward-socks5   /               127.0.0.1:9050 .

and then i restartet the service, and yes rebooting was also a try.

The python code:

Code
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium import webdriver

prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
prox.autodetect = False
prox.http_proxy = "https://localhost:8118"
#prox.socks_proxy = "https://localhost:8118"
prox.ssl_proxy = "https://localhost:8118"

capabilities = webdriver.DesiredCapabilities.CHROME
prox.add_to_capabilities(capabilities)


options = webdriver.ChromeOptions()
options.add_argument("ignore-certificate-errors")


# initialize the driver
driver = webdriver.Chrome(options=options, desired_capabilities=capabilities)

driver.get('https://myip.is/')


any ideas how to solve the problem ?


Outputs:

cat /proc/version:

Linux version 5.4.51-v7+ (dom@buildbot) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1327 SMP Thu Jul 23 10:58:46 BST 2020


cat /etc/os-release:


PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"




0u1law
Have you tried starting tor before launching the program?

Also if you need, selenium running on firefox trough tor I’ve the code / geckodriver working which I wrote to pentest my web app
(Sep 4, 2020 11:13 PM)Argonaut.exe Wrote:  Have you tried starting tor before launching the program?

Also if you need, selenium running on firefox trough tor I’ve the code / geckodriver working which I wrote to pentest my web app

Yes i tried almost everything i found on google. sounds interesting would you like to share your code ?

and i can install firefox on my raspberry but cant find the matching geckodriver. i installed it manually but without success. it would be a pleasure if you can give me the links for firefox and geckodriver. iceweasel doesnt exist anymore right ?
(Sep 5, 2020 10:52 AM)0u1law Wrote:  Yes i tried almost everything i found on google. sounds interesting would you like to share your code ?

and i can install firefox on my raspberry but cant find the matching geckodriver. i installed it manually but without success. it would be a pleasure if you can give me the links for firefox and geckodriver. iceweasel doesnt exist anymore right ?



so I needed some time to recover the project from the server is running on,

here the small piece of code to init selenium (remove every import you don't need I was a bit too lazy to do that)


Code
from __future__ import print_function

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

from selenium.webdriver import Firefox, FirefoxProfile
from selenium.webdriver.firefox.options import Options

from selenium.webdriver.common.action_chains import ActionChains



class ExampleLoginBot():
    def __init__(self, username, password):
        profile = FirefoxProfile()
        profile.set_preference('network.proxy.type', 1)
        profile.set_preference('network.proxy.socks', '127.0.0.1')
        profile.set_preference('network.proxy.socks_port', 9050)
        binary= FirefoxBinary('/home/Example/firefoxen/firefox')
        options = Options()
        options.set_headless(False) ####headless

        self.browser = webdriver.Firefox(options=options, executable_path=r'/home/Example/geckodriver', firefox_binary=binary, log_path="/home/Example/gecko.log", firefox_profile=profile)
        self.username = username
        self.password = password


I will zip firefox and geckodriver , PM soon.

About the use, keep in mind you should bind tor to the port 9050 or anyone just change it in the code, it will be used as proxy by selenium

(in my code I also added in the init a SYS signal to change the node of tor... but can't share my whole project :P )



edit: PM sent with gecko and firefox


Possibly Related Threads...
Thread / Author Replies Views Last Post
by hankmoneymanFeb 21, 2026 07:36 AM 1 143 Feb 21, 2026 07:36 AM
Last Post: sudowoodoking
[Python] by Luffy-_-Aug 20, 2023 02:06 AM 12 446 Aug 20, 2023 02:06 AM
Last Post: Lucky4L
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 631 Aug 20, 2023 01:44 AM
Last Post: Lucky4L