• word常见操作检索


     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.无中间状态信息,让人心慌。

  • 相关阅读:
    读TIJ -2 一切都是对象
    codeforces 437C The Child and Toy
    关于js基础easy忘记的那些事儿
    项目启动会应该注意的几点
    SSH-Struts(一)——基本原理
    公益代理-开发人员的福音
    【手打】LZW编码的C/C++实现
    tab group of firefox
    Sort Colors -- LeetCode
    Qt 学习之路:自定义事件
  • 原文地址:https://www.cnblogs.com/kamishiroshinchi/p/13375279.html
Copyright © 2020-2023  润新知