0

I am running Prawler to get proxies.

I installed this with the instructions given on GitHub. It works fine too, but I would like to add a choice option in it.

To get a proxies, I use this following code:

import Prawler;
Prawler.get_proxy_txt("proxy_list.txt", 50, "http", "elite")'

I would like this to ask me which type of proxy I need. For example, the expected output:

Choose Proxy type,
option 1 - http
option 2 - socks4
option 3 - socks5
choose one option from above >

If I type 1 and press enter, it replaces the proxy type to http

If I type 2 and press enter, it replaces the proxy type to socks4

If I type 3 and press enter, it replaces the proxy type to socks5

In my main code:

for http option,

import Prawler;
Prawler.get_proxy_txt("proxy_list.txt", 50, "http", "elite")'

for socks4 option,

import Prawler;
Prawler.get_proxy_txt("proxy_list.txt", 50, "socks4", "elite")'

for socks5 option,

import Prawler;
Prawler.get_proxy_txt("proxy_list.txt", 50, "socks5", "elite")'

I don't know how to make it ask for my choice option here in Python. I am new to python. Kindly help me to proceed further.

1 Answer 1

1

I haven't tried it with Prowler, but this should work.

It stores the input as a str named option.

It checks to see if the input option is in the dict named proxy_types. It will loop until you enter either 1, 2, or 3.

When a valid input is found, it uses option as a key to retrieve the correct value from proxy_types - either http, socks4, or socks5. It then breaks out of the loop, and calls get_proxy_txt with the chosen proxy_type.

import Prawler

proxy_types = {"1": "http", "2": "socks4", "3": "socks5"}

while True:
    option = input("""Choose Proxy type,
    option 1 - http
    option 2 - socks4
    option 3 - socks5
    choose one option from above > """)
    if option not in proxy_types:
        print("Invalid option selected. Choose again.")
        continue

    proxy_type = proxy_types[option]
    break

Prawler.get_proxy_txt("proxy_list.txt", 50, proxy_type, "elite")

Not the answer you're looking for? Browse other questions tagged .