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

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

于 2023-06-27 发布 文件大小:21.32 kB
0 196
下载积分: 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 个回复

  • Form of the tab page to set up and use Lookbar also added a form of color settin...
    窗体的tab页设置和Lookbar的使用方法,还加了窗体的颜色设置。-Form of the tab page to set up and use Lookbar also added a form of color settings.
    2022-08-04 05:06:02下载
    积分:1
  • 远程教育系统
    DistanceLearning系统dealswith不同层次的培训和技能开发theemployee和将占员工的表现,训练对验证工作能力。描述远程教育系统将givean额外的旋转来训练员工通过网络andcommunication技术。这种创新会给许多受益toorganization在培训员工。它是用户友好projectswere用户可以工作在有自己的一席之地,并在方便的时间。 Thissystem主要由三个不同的角色。主办单位:监视wholesystem。管理员:发送响应theemployee和维护存储库员工:用户系统,培训机构要求的。总任务管理客户端注册书籍访问要求考试要求额外的时间
    2022-02-20 22:25:37下载
    积分:1
  • 访问firebird和interbase数据库的vcl控件
    访问firebird和interbase数据库的vcl控件-visit interbase database and the VCL controls
    2023-03-26 18:50:04下载
    积分:1
  • 本软件是在ads上编译的串口实验程序,很好的,是针对lpc22xx的...
    本软件是在ads上编译的串口实验程序,很好的,是针对lpc22xx的-the software is compiled in ads Serial experimental procedure, very good, against the lpc22xx
    2022-09-26 16:00:03下载
    积分:1
  • remoting 入门,很经典的几个例子,是源代码的,不错哦
    remoting 入门,很经典的几个例子,是源代码的,不错哦-remoting entry, it is a few examples of classic and is the source code, yes oh
    2023-07-10 23:35:03下载
    积分:1
  • 对BMP图像进行线性变换,包括点运算,阈值变换,灰度拉伸等...
    对BMP图像进行线性变换,包括点运算,阈值变换,灰度拉伸等-BMP image of the linear transformation, including point of operation, the threshold transformation, gray stretch, etc.
    2022-02-09 13:14:44下载
    积分:1
  • CFileDialog derivatives, so that it not only can, they can also choose Contents
    派生CFileDialog,使之不仅可选择文件,还可选择目录-CFileDialog derivatives, so that it not only can, they can also choose Contents
    2022-03-18 02:09:18下载
    积分:1
  • 嵌入式软件工程师必须掌握的基本功,与普通C编程的侧重点有很大的不同!...
    嵌入式软件工程师必须掌握的基本功,与普通C编程的侧重点有很大的不同!-embedded software engineers must master the basic skills, and ordinary C programming focus is very different!
    2023-04-24 18:35:03下载
    积分:1
  • 本程序的功能:修改文件或目录的创建、修改、和属性…
    本程序功能: 1、修改文件或目录的产生、修改时间,及各种属性; 2、能够自动判断本程序是否重载,并给出提示; 3、增加了隐藏到系统托盘的功能,并修改了关闭功能; 4、实现对话框的动画弹出和消隐,增强程序的美观性 5、增加了系统热键功能,窗口隐藏时Ctrl+Alt+X可以呼出; 6、置窗体为最顶层显示,并去掉了任务栏的窗体 7、新增了鼠标在主窗口上移动时,显示手形光标功能。-this program functions : a revised list of documents or create, modify, and attributes; 2, can automatically judge whether the procedure heavy, and gives prompts; 3, a system tray to hide the functions and revised the closing function; Four realize right then pop-up frames of animation and hidden, to enhance the beauty of procedure 5, a system hotkey function, the window hidden when Ctrl Alt X can exhale; 6, home to the most top-level windows, and removed the task bar of Form 7, a mouse in the new window on the main mobile, hand-shaped display the cursor function.
    2023-06-13 13:20:03下载
    积分:1
  • Library system
    一个用C++实现的图书馆管理系统,主要是用MFC实现的-Library system
    2022-02-16 01:44:26下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载