首先,我正在做一个
Windows应用程序.不是Web应用程序.
现在我正在申请将SMS(短消息)从System发送到Mobile.
在这里,我使用http URL来推送具有参数To(number)和Msg(测试消息)的消息.
形成URL之后,就像
发送此URL后,我在浏览器窗口中收到一些文本,如“Message Send Successfully”.
我想阅读文本并存储在数据库中.
我的问题是:我如何从网络浏览器中读取文本.
请抱着我!
解决方法
使用.NET,请参阅
WebClient Class –
提供向URI标识的资源发送数据和从其接收数据的常用方法.
提供向URI标识的资源发送数据和从其接收数据的常用方法.
在这里看过几次,例如fastest c# code to download a web page
编辑:System.Net.WebClient类未连接到Web应用程序,可以轻松地在控制台或winforms应用程序中使用. MSDN链接中的C#示例是一个独立的控制台应用程序(编译并运行它来检查):
using System; using System.Net; using System.IO; public class Test { public static void Main (string[] args) { if (args == null || args.Length == 0) { throw new ApplicationException ("Specify the URI of the resource to retrieve."); } WebClient client = new WebClient (); client.Headers.Add ("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); Stream data = client.OpenRead (args[0]); StreamReader reader = new StreamReader (data); string s = reader.ReadToEnd (); Console.WriteLine (s); data.Close (); reader.Close (); }
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。