Change Tor IP using Python Stem for web scraping

Опубликовано: 03 Октябрь 2024
на канале: Tan En De
3,817
79

Change Tor IP during web scraping in Python. Further anonymizing step is to consider changing user-agent in the header. Also, stop tor service when not in use.

Links for the code: https://github.com/endeneer/change-to...

Note: For Windows, here are the steps:
1) There is no need to install Tor service. Just make sure you have the normal Tor Browser installed.
2) Generate HashedControlPassword
- run the command: tor --hash-password YourPasswordhere | more
- in the video I used abc123 as YourPasswordhere
3) Copy the hash, then edit TorBrowser/Browser/TorBrowser/Data/Tor/torrc
- In the torcc file, add in these two lines:
HashedControlPassword paste_the_hash_copied_just_now
CookieAuthentication 1
4) Start Tor Browser
5) Run the python program as in the video
- there are three things to change:
a) Line 9, change the port 9051 to 9151
b) Line 12, change the port 9050 to 9150
c) Line 16, change the password you set (in clear text, not the hashed one)