早上好,我是这个地方的新手,并且在让任何结果发挥作用方面遇到了很多问题。
我目前正在使用视觉工作室社区中的C#并使用你的视频管作为参考,但我不能让它有效地工作(我认为它在一个循环中)并做其他动作。
我试图从桌面上的文本文件中获取URL列表,或者通过用户将其输入到字段:
EG:程序打开HE将IP放在一个文本框中,点击提交程序运行并完成。
或者如果它从桌面C中提取IP列表:然后它会在使用循环时将其添加到网站?
例如:
我目前的代码如下所示:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HTTPcollect_Windows_Form_App
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
List<string> IPs = new List<string>();
WebClient web = new WebClient();
String html = web.DownloadString("http://www.ipvoid.com/scan/8.8.8.8/");
MatchCollection m1 = Regex.Matches(html, @"IP Address.*<strong>(.+?) <\/strong>", RegexOptions.Singleline);
foreach (Match m in m1)
{
string IP = m.Groups[1].Value;
IPs.Add(IP);
}
listBox1.DataSource = IPs;
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}