问题描述
Hello程序员,
这是我在代码项目站点上的第一个问题,我希望能得到一个答案-我最好的程序员朋友向我推荐了这个站点,因为我是最好的-并且我正在寻找解决方案;
我需要从外部网页获取选定的数据...
我已经尝试通过获取所需的页面源代码进行尝试,并且可以通过以下代码来做到这一点:
Hello Programmers,
this is my first question at code project site and I wish I could get an answer - my best programmer friend suggested this site to me as the best - and I''m searching for a solution for;
I need to get selected data from an external web page...
I''ve tried by fetching the desired page source code and I could do that by the following code:
...
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
...
private void BtnGetSc_Click(object sender, EventArgs e)
{
string url = TbUrl.Text;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
RtbSC.Text = sr.ReadToEnd();
sr.Close();
}
...
但是我被困在将源代码转换为C#控件的过程中,所以有什么建议吗?!
提示:用直言不讳;我需要读取任何网页并从中获取文本框值.
预先感谢您的答复:)
but I''m stuck in converting this source code to a C# controls, so any suggestion??!
Hint: in outher words; I need to read any web page and fetch a text box value from it.
thanks in advance for any reply :)
推荐答案
这篇关于获取网页源代码并检索其控件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!