百度網盤搜索工具_2019


百度網盤搜索工具

1.寫在前面

經常搜索百度網盤里的資源,以前做了個數據來源來自盤多多,現在不能使用了。所以就又找了一個搜索網站史萊姆http://www.slimego.cn。

2.分析

通過獲得查詢頁面的源數據,得到記錄總數,分頁數,搜索數據集合。

3.程序實現

下面將貼出實現該程序的關鍵代碼。

 1         /// <summary>
 2         /// 通過正則表達式獲得百度網盤文件
 3         /// </summary>
 4         private void GetNetFilesDo()
 5         {
 6             string Keyword = TextBoxKeyword.Text.Trim();
 7             string url = string.Format("http://www.slimego.cn/search.html?q={0}&page=1&rows=20", Keyword);
 8             string html = GetHtmlContent(url);
 9 
10             //獲得總頁數和總記錄數
11             GetPageInfo(html);
12             Invoke(new SetProgressMaxDelegate(SetProgressMax), RecordCount);
13             if (RecordCount <= 0)
14             {
15                 Invoke(new SetButtonStartDelegate(SetButtonStart), true);
16                 return;
17             }
18 
19             //循環頁面
20             for (int i = 1; i <= PageCount; i++)
21             {
22                 if (i >= 2)//第1頁已經查到了,就不用查了
23                 {
24                     url = string.Format("http://www.slimego.cn/search.html?q={0}&page={1}&rows=20", Keyword, i);
25                     html = GetHtmlContent(url);
26                 }
27 
28                 int seeks = html.IndexOf("<div style=\"display:table\">");//開始位置
29                 int seeke = html.IndexOf("<div id=\"pagesplit\" class=\"m-pagination\"></div>");//結束位置
30                 string content = html.Substring(seeks + 0, seeke - seeks - 15).Trim();
31                 Regex rxGetInfo = new Regex("<div style=\"display: table-cell\" class=\"searchCell\">.*?</div>", RegexOptions.Singleline);
32                 MatchCollection matches = rxGetInfo.Matches(content);
33 
34                 //循環每1頁
35                 for (int j = 0; j < matches.Count; j++)
36                 {
37                     if (matches[j].Success)
38                     {
39                         string strMatch = matches[j].Value;
40 
41                         MatchCollection match1 = Regex.Matches(strMatch, "<a rel=\"noreferrer\".*?</a>", RegexOptions.Singleline);//文件名
42                         MatchCollection match2 = Regex.Matches(strMatch, "<span class=\"ftype\">.*?</span>");//類別
43                         MatchCollection match3 = Regex.Matches(strMatch, "<span class=\"size\">.*?</span>");//大小
44                         MatchCollection match4 = Regex.Matches(strMatch, "<span class=\"upload\">.*?</span>");//時間
45                         MatchCollection match5 = Regex.Matches(strMatch, "<a rel=\"noreferrer\".*?</a>", RegexOptions.Singleline);//文件地址
46                         MatchCollection match6 = Regex.Matches(strMatch, "<span class=\"home\">.*?</span>", RegexOptions.Singleline);//分享地址
47                         if (match1 == null || match2 == null || match3 == null || match4 == null || match5 == null || match6 == null) continue;
48 
49 
50                         NetFileInfo file = new NetFileInfo();
51                         file.ID = (i - 1) * PageSize + j + 1;
52                         file.FileFullName = CommonLib.RemoveHTML(match1[0].Value).Trim();
53                         file.FileName = file.FileFullName;
54                         file.ExtName = GetExtName(file.FileFullName);
55                         file.Tag = GetTypeName(file.ExtName);
56                         file.FileSize = CommonLib.RemoveHTML(match3[0].Value);
57                         string TimeSize = CommonLib.RemoveHTML(match4[0].Value);//上傳: 2018年07月20日 07時27分
58                         TimeSize = TimeSize.Substring(TimeSize.IndexOf(" ") + 1, TimeSize.LastIndexOf(" ") - 4);
59                         file.FileTime = TimeSize;
60                         file.ShareFileSite = GetShareFileSite(match1[0].Value);
61                         string ShareName = CommonLib.RemoveHTML(match6[0].Value).Replace("查看用戶", "").Replace("的所有分享", "");
62                         file.ShareName = ShareName;
63                         file.ShareSite = GetShareSite(match6[0].Value);
64 
65                         Invoke(new GridRowAddDelegate(GridRowAdd), file);
66                         Invoke(new SetProgressDelegate(SetProgress), file.ID);
67                     }
68                 }
69             }
70 
71             Invoke(new SetButtonStartDelegate(SetButtonStart), true);
72         }
View Code

4.程序界面

百度網盤搜索工具

5.功能

1、搜索任意名稱的百度網盤共享文件。
2、鼠標左鍵雙擊打開網盤地址。
3、鼠標右鍵點擊彈出上下文菜單。打開、復制網盤地址及打開、復制分享者主頁。
4、可以導出搜索結果。

下載地址:https://pan.baidu.com/s/16RidPx2VLn7CCUHcQ-aPCw


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM