Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 2420

Need help from python devs

by Zikola - 07 June, 2020 - 06:15 PM
This post is by a banned member (Zikola) - Unhide
Zikola  
Contributor
4.268
Posts
139
Threads
5 Years of service
#1
ok guys
i have this code who do some request to the web
but due its proxyless so its useless
so i have no idea how python works but i know basics 
[Image: feelssadman.png]
can someone explain how to make this bot in every request use the proxie that in the proxy file ( rotate proxy )
[Image: 68747470733a2f2f6d656469612e67697068792e...792e676966]
This post is by a banned member (clap) - Unhide
clap  
Godlike
519
Posts
134
Threads
5 Years of service
#2
Well you'll need to load in the proxylist which can be done like so,
Code:
 
try:
    proxy_list = open('proxies.txt', 'r', encoding='utf8', errors='ignore').readlines()
except IOError:
    # Your error handling here

Next you need to get a random proxy from that file or make a function that does that for you. Each work the same.
Code:
 
import random

def proxy_machine():
    proxy_list = open('proxies.txt', 'r', encoding='utf8', errors='ignore').readlines()
    
    return random.choice(proxy_list).strip()

Or
Quote:import random

proxy_list = open('proxies.txt', 'r', encoding='utf8', errors='ignore').readlines()

def check_login_whatever():
    global proxy_list

    randomProxy = random.choice(proxy_list).strip()
    
    socks4 = {'https': f'socks4://{randomProxy}'}
    socks5 = {'https': f'socks5://{randomProxy}'}
    https = {'https': f'https://{randomProxy}'}

Now once you have actually gotten the proxies, formatted them, now you need to actually pass them into the requests object. If you're using a requests session, you can do `session.proxies = socks4` or whatever and if you're using a requests object you can do `requests.get(url, proxies=socks4)`

Hope this'll help you learn some more about Python.
Always confirm via PM before dealing with me.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)