码迷,mamicode.com
首页 > 其他好文 > 详细

word常见操作检索

时间:2020-07-25 09:12:50      阅读:65      评论:0      收藏:0      [点我收藏+]

标签:htm   chrome   create   graph   point   exp   end   except   rom   

技术图片
 1 using System;
 2 using System.Net;
 3 using System.IO;
 4 using System.Text;
 5 using System.Text.RegularExpressions;
 6 using System.Net.Security;
 7 using System.Security.Cryptography.X509Certificates;
 8 
 9 namespace ConsoleApp1
10 {
11   
12     class Program
13     {
14         public static string DoRequest(string Url, string cookieStr)
15         {
16             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
17 
18             request.Timeout = 1000 * 900;
19 
20             request.Headers.Add(HttpRequestHeader.Cookie, cookieStr);
21 
22             request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36";
23 
24             ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;// SecurityProtocolType.Tls1.2;
25 
26             string back = "";
27             try
28             {
29                 WebResponse response = request.GetResponse();
30                 StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
31                 back = reader.ReadToEnd();
32                 reader.Close();
33                 reader.Dispose();
34                 response.Close();
35             }
36             catch (Exception ex)
37             {
38 
39                 back = ex.Message;
40             }
41 
42 
43 
44             return back;
45         }
46 
47         static void Main(string[] args)
48         {
49             Console.WriteLine("请输入关键字");
50             string keyword = Console.ReadLine();
51             string cookie = "";
52             for (int i = 1; i < 64; i++)
53             {
54                 string url = "https://www.php.cn/topic/word?p=" + i.ToString();
55                 string str = DoRequest(url, cookie);
56                 if (str.IndexOf(keyword) != -1)
57                     Console.WriteLine(url);
58             }
59             Console.WriteLine("检索完毕");
60             Console.ReadLine();
61         }
62     }
63 }
View Code

缺点包含且不仅包含:

1.不支持多关键字;

2.无中间状态信息,让人心慌。

word常见操作检索

标签:htm   chrome   create   graph   point   exp   end   except   rom   

原文地址:https://www.cnblogs.com/kamishiroshinchi/p/13375279.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!