I am doing web scraping, and I am using tor as my proxy service. I am using ubuntu 20.4.x and python 3.9.
As I have installed tor in my local system, I am using:
proxies = {
'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'
}
My sample code looks like:
import requests
from fake_useragent import UserAgent
url = "https://www.google.com/"
proxies = {
'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'
}
# Using fake headers to change the request header
headers = {'User-Agent': UserAgent().random}
try:
resp = requests.get(url, proxies=proxies, headers=headers, timeout=(10, 10))
except Exception as e:
print(e)
Let's say I have a remote server with IP xx.xx.xx.xx, Can I install tor in this remote server and use the particular server port in my local machine to use proxy, i.e. xx.xx.xx.xx:9050.
If yes, can I use it in my code like:
proxies = {
'http': 'socks5://xx.xx.xx.xx:9050',
'https': 'socks5://xx.xx.xx.xx:9050'
}
How to get it installed?