How do I check the proxies from .txt without specifying the port in C#

Kuba 21 Reputation points
2020-11-01T18:02:06.803+00:00

I'd like to know how to do a loop check if a given list of proxy is alive without specifying the port as it is easier done in python for example

list = open("files/proxies.txt", "r").readlines()

    while(True):
        try:
            proxy = {"https": "{}".format(random.choice(list).rstrip())}
            if(len(proxy['https']) <= 1):
                continue
            ret = requests.get("https://www.google.nl", proxies=proxy, timeout=2)

In C# each proxy I have to set manually and specify the port, is there any workaround to do this? So far I've come up with this

public bool GetProxy()
        {
            var proxies = File.ReadLines("../../proxies.txt").ToList();

            while (true)
            {
                try
                {

                }
            }
        }

but I have no clue how to loop throughout the entire proxy list, I found it easier to code it in python instead of C# so I'd love to see this kind of facility in C#.

Community Center | Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2020-11-01T18:15:26.357+00:00

    C# is not currently supported here on QnA. They're actively answering questions in dedicated forums here.
    https://social.msdn.microsoft.com/Forums/en-US/home?forum=csharpgeneral

    --please don't forget to Accept as answer if the reply is helpful--

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.