From d7442a18a5881fe041da93c149d74e901884b4bb Mon Sep 17 00:00:00 2001 From: Ben Busby <33362396+benbusby@users.noreply.github.com> Date: Sun, 25 Oct 2020 18:33:45 -0400 Subject: [PATCH] Refactor acquire_tor_conn -> acquire_tor_identity Also updated travis CI to set up tor --- .travis.yml | 4 +++- app/request.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 110c0ea..800f560 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: python python: 3.6 before_install: - - sudo apt-get -y install libgnutls28-dev + - sudo apt-get -y install libgnutls28-dev tor + - sudo cat rc/torrc > /etc/tor/torrc + - sudo systemctl tor start install: - pip install -r requirements.txt script: diff --git a/app/request.py b/app/request.py index c8fdea0..5f9abcd 100644 --- a/app/request.py +++ b/app/request.py @@ -19,7 +19,7 @@ DESKTOP_UA = '{}/5.0 (X11; {} x86_64; rv:75.0) Gecko/20100101 {}/75.0' VALID_PARAMS = ['tbs', 'tbm', 'start', 'near', 'source', 'nfpr'] -def acquire_tor_conn(): +def acquire_tor_identity(): with Controller.from_port(port=9051) as c: c.authenticate() c.signal(Signal.NEWNYM) @@ -151,10 +151,10 @@ class Request: attempt += 1 if attempt > 5: return requests.get(self.root_path + 'tor-reject?q=' + query) - acquire_tor_conn() + acquire_tor_identity() return self.send(base_url, query, attempt) return response -acquire_tor_conn() +acquire_tor_identity()