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

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

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

  • SQLSever 数据库贴付机工具 (SQLServer 2000 年)
    SQLSever 数据库贴付机是 sqlserver 2000 贴付机数据库文件 (包括日志文件)。它使用 C# 作为编程语言,可以创建,修饰和在 VS 2013 IDE 中进行编译。geneally 说,它可以用作 auxilury 工具附加 DB 文件为安装程序向导。它支持两种类型的连接方法包括 windows 系统授权和数据库用户登录在 (与有效的密码)。
    2022-02-24 09:34:49下载
    积分:1
  • huffman tree 问题描述:设一份电文中有不同出现频率的字符,为了提高电文的输入和翻译效率,必须有一套简短而又不会产生歧义的字符代码。试根据哈夫曼算法,...
    huffman tree 问题描述:设一份电文中有不同出现频率的字符,为了提高电文的输入和翻译效率,必须有一套简短而又不会产生歧义的字符代码。试根据哈夫曼算法,对电文中的不同字符,构造出一棵哈夫曼树,对每个字符进行编码。-Huffman tree Problem description : Let a message different frequency of the characters, in order to enhance the input and message translation efficiency, we must have a brief but no ambiguity of the characters code. Examination under Huffman algorithm, the message of characters, construct a Huffman tree for each character coding.
    2022-10-09 01:35:04下载
    积分:1
  • Inside COM
    这是本书的样例代码。
    2022-03-25 15:57:35下载
    积分:1
  • VC++鼠标捕捉的使用方法
    Windows 95 程序设计中的一个小例子。今天再次复习一遍。 学习鼠标捕捉的使用方法: SetCapture() ReleaseCapture(); 请点击左侧文件开始预览 !预览只提供20%的代码片段,完整代码需下载后查看 加载中 侵权举报
    2022-03-28 21:30:08下载
    积分:1
  • XP style interface source code, the development environment VC.
    XP风格界面源代码,在VC.NET环境下开发-XP style interface source code, the development environment VC.
    2022-04-27 06:19:02下载
    积分:1
  • MATLAB实现shepp-logan头模型重建
    MATLAB程序来实现三维shepp-logan头模型FDK重建,生成头模型不同角度下投影数据并进行三维锥束重建
    2022-02-07 01:48:59下载
    积分:1
  • 输入中缀式,转换为后缀式,并输出结果。如2+2*2,得出结果为6....
    输入中缀式,转换为后缀式,并输出结果。如2+2*2,得出结果为6.-Input is made up of type, into a suffix-type, and output. Such as 2+2* 2, the results for the 6.
    2022-01-24 08:55:45下载
    积分:1
  • 本程序设计分为服务器应用程序及客户机应用程序部分,采用Socket套接字库网络编程。(UDP)和(TCP/IP)相结合的连接方式,及解决了数据传输的时效性又能保...
    本程序设计分为服务器应用程序及客户机应用程序部分,采用Socket套接字库网络编程。(UDP)和(TCP/IP)相结合的连接方式,及解决了数据传输的时效性又能保证数据在传输的过程中不会丢失。另外程序采用多个线程来避免程序阻塞。具体设计思路及部分代码如下: 程序设计目的:首先就是完成课设任务啦(大二课设内容)其他目的: 1:练习使用套接字进行网络编程。 2:练习使用自定义消息。 3:练习多线程方面的编程思想。 4:练习使用各种控件。 -This procedure is divided into server application design and part of the client application using Socket socket network programming library. (UDP) and (TCP/IP) connection method of combining, and resolved the timeliness of data transmission but also ensures that the process of data transmission will not be lost. Other procedures to avoid the use of multiple threads blocking procedures. Specific design ideas and some code as follows: program design purposes: first mission is set up you finish class (sophomore class for the content of) other purposes: 1: Practice using the socket network programming. 2: Practice the use of custom message. 3: practice aspects of multi-threaded programming idea. 4: Practice using a variety of controls.
    2022-03-23 04:56:54下载
    积分:1
  • 通过提高名称杀死的进展,
    通过进程名字杀死进程,进程名字忽略大小写,可以带扩展名也可不带扩展名,使用非常方便- Kills the advancement through the advancement name, the advancement name neglects the big small letter, may bring the extension also to be possible not to bring the extension, the use extremely to facilitate
    2022-03-01 01:37:09下载
    积分:1
  • the process re
    在程序中再运行一个exe-the process re-running a exe
    2022-04-11 07:24:08下载
    积分:1
  • 696518资源总数
  • 106161会员总数
  • 5今日下载