登录
首页 » Windows开发 » 获取网页源代码的三种方法,并将其保存到文件中

获取网页源代码的三种方法,并将其保存到文件中

于 2023-06-27 发布 文件大小:21.32 kB
0 175
下载积分: 2 下载次数: 1

代码说明:

应用背景在这组片段,我现在给你的三个方法,下载并保存到一个文件中的一个网页的源代码,有兴趣。第一个使用WebClient类和第三个使用WebRequest。它们都是系统的一部分,净名称空间。你应该注意通过HttpWebRequest获取源被认为是一种过时的做法。关键技术让我们先从几个使用语句开始:利用系统;使用System.IO;使用system.windows.forms;注:由于我们使用的控制台应用程序,在这个例子中,请注意system.windows.forms命名空间是不包括在新项目自动所以你要增加它的引用(解决方案资源管理器- & gt;引用& gt;(右击)添加引用比下。净标签找到命名空间)。不包括下面的代码在main()功能:和公司;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及;及使用(WebClient客户端=新webclient()){客户端下载文件。(“HTTP:/ / www.google。COM”,application.startuppath + @“LOG1。txt”);}/ /方法2字符串源=新webclient()。downloadstring(“HTTP:/ / www.google。COM”);StreamWriter SW =新StreamWriter(application.startuppath + @“log2。txt”,真的);软件:写(来源);申银万国();/ /方法3 -过时WebRequest req = HttpWebRequest。创造(“HTTP:/ / www.google。COM”);方法=“得到”的要求;串供应链;(读者使用StreamReader =新的StreamReader(REQ。getresponse()。getresponsestream())){readtoend() SC =读者;}将作家=新StreamWriter(application.startuppath + @“log3。txt”,真的);作者:写(源);作家();此代码将创建包含源代码的三个文本文件(在我们的情况下,谷歌的索引页)。你可以在同一个目录中找到这些文件作为可执行文

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 透明时钟的例子,可以直接运行
    透明时钟的例子,可以直接运行-transparent clock example, can directly run
    2022-04-14 12:36:28下载
    积分:1
  • Window数据, 压缩huffman算法
    Window数据, 压缩huffman算法-windows data ,compress huffman arithmetic
    2022-07-15 15:34:28下载
    积分:1
  • 2023-08-06 04:55:03下载
    积分:1
  • 把flash文件包含到程序中,可以与文件中设定的fscommand互动
    把flash文件包含到程序中,可以与文件中设定的fscommand互动-The flash file contains the procedures, and documents can be set fscommand interaction
    2022-03-12 18:10:56下载
    积分:1
  • 这个是dll中如何取得参数的方法,有完整的程序,这个是6.0的...
    这个是dll中如何取得参数的方法,有完整的程序,这个是6.0开发的-this is how the parameters achieved, a complete set of procedures is the development of the 6.0
    2022-03-25 08:21:14下载
    积分:1
  • The concept of object
    面向对象编程概念的一些学习心得,希望能给大家帮助-The concept of object-oriented programming some of the learning experience, could you help
    2022-04-17 04:00:58下载
    积分:1
  • h264编码源程序,将yuv视频序列编码为h264文件
    h264编码源程序,将yuv视频序列编码为h264文件-h264 encoder,encode yuv video series to h264 file
    2022-03-13 06:54:15下载
    积分:1
  • " Visual+ C++ case development," the source code package including case...
    《Visual+C++案例开发》配套源代码 包括大案例和小案例(API绘图小案例,wav文件操作等)-" Visual+ C++ case development," the source code package including case and small case (API mapping of small cases, wav file operations, etc.)
    2022-04-07 15:29:17下载
    积分:1
  • 从SMBIOS中获取内存条信息的控制台程序
    从SMBIOS中获取内存条信息的控制台程序  请在cmd窗口打开
    2022-10-26 04:30:03下载
    积分:1
  • This article shall describe a very simple approach to working with a GPS device...
    This article shall describe a very simple approach to working with a GPS device within the context of a Visual Basic 2005 application. This article does not address how the GPS device works or everything that can be gleaned from the NEMA 0183 string outputted from most GPS devices rather, the article is intended for those just interested in getting present position from a GPS and using that point to do something interesting like show you where you are on a map.-This article shall describe a very simple approach to working with a GPS device within the context of a Visual Basic 2005 application. This article does not address how the GPS device works or everything that can be gleaned from the NEMA 0183 string outputted from most GPS devices rather, the article is intended for those just interested in getting present position from a GPS and using that point to do something interesting like show you where you are on a map.
    2022-08-19 17:43:14下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载