C# 代理IP的winform
python
using System;
using System.Net;
using System.Windows.Forms;
namespace ProxyIPWinForms
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void btnSendRequest_Click(object sender, EventArgs e)
{
string proxyAddress = $"http://{txtProxyIP.Text}:{txtProxyPort.Text}";
WebProxy proxy = new WebProxy(proxyAddress);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com");
request.Proxy = proxy;
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
MessageBox.Show($"Status Code: {response.StatusCode}");
response.Close();
}
catch (WebException ex)
{
MessageBox.Show($"Error: {ex.Message}");
}
}
}
}