C# 代理IP的winform

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}");
            }
        }
    }
}
相关推荐
期待のcode3 分钟前
Java的单例模式
java·开发语言·单例模式
Aliex_git11 分钟前
内存堆栈分析笔记
开发语言·javascript·笔记
LYOBOYI12322 分钟前
qml练习:创建地图玩家并且实现人物移动(2)
开发语言·qt
电商API&Tina27 分钟前
【电商API接口】多电商平台数据API接入方案(附带实例)
运维·开发语言·数据库·chrome·爬虫·python·jenkins
1001101_QIA31 分钟前
【C++笔试题】递归判断数组是否是递增数组
开发语言·c++
zhangx1234_32 分钟前
C语言 题目2
c语言·开发语言
YJlio37 分钟前
网络与通信具总览(14.0):从 PsPing 到 TCPView / Whois 的联合作战
开发语言·网络·php
yong999038 分钟前
超宽带系统链路 MATLAB 仿真
开发语言·算法·matlab
yaoxin52112339 分钟前
278. Java Stream API - 限制与跳过操作全解析
java·开发语言·python
iCheney!43 分钟前
php生成赛博像素风头像
开发语言·php