Reputation: 1
I have checked other posts but they do not seem to resolve this.
this is my code.
def main():
while True==True:
random_proxy = random.choice(read)
proxies = {
proxy_type: random_proxy
}
response = requests.get('https://manacube.com/play/', cookies=cookies, proxies=proxies, headers=headers)
if response.status_code == 200:
print("Page View Sent (Code 200)")
else:
print("Error")
for x in range (int(t)):
Thread(target=main).start()
THE ERROR IM GETTING IS :
Traceback (most recent call last):
File "C:\Users\name\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\name\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "bot.py", line 49, in main
response = requests.get('https://url.com/play/', cookies=cookies, proxies=random_proxy, headers=headers)
File "C:\Users\name\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\name\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\mazin\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 519, in request
settings = self.merge_environment_settings(
File "C:\Users\name\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 700, in merge_environment_settings
no_proxy = proxies.get('no_proxy') if proxies is not None else None
AttributeError: 'str' object has no attribute 'get'
I am not sure if this is a dumb error but i am new at python so please do not make fun of me, please help if you can, i want to choose a random proxy out of proxies.txt and use it every request.
so
request 1: 111.68.31.155:8080 request 2: 203.210.84.198:8080 request 3: 150.136.120.227:3128
Upvotes: 0
Views: 2194
Reputation: 1
I tried this and it worked with me
It's using:
pro = {
'http://': random_proxy,
'https://': random_proxy
}
Instead of:
proxies = {
proxy_type: random_proxy
}
Upvotes: 0