如何使用.txt列表中的关键字搜索网页
本文关键字:关键字 搜索 搜索网 网页 何使用 txt 列表 | 更新日期: 2023-09-27 18:30:56
我正在尝试查找有关如何导入关键字.txt列表以放入搜索函数的教程或帮助:
http://www.website.com/search.php?word=WORDHERE
它将是此类 URL,但我希望它遍历列表中的每个项目并将 wordhere 替换为该单词,以便它搜索列表中的每个单词。
如果显示为"未找到匹配项",它将创建一个包含所有不匹配项的新列表。我不在乎它是否将其导出到新.txt或者它是否涌入另一个文本框。两者都有效。
如果搜索匹配,它将简单地忽略它并移动到下一个。
我是新手:(把我送到一些帮助:P
假设.txt文件每行包含一个单词,下面是一个简单的解决方案:
string[] keywords = System.IO.File.ReadAllLines(@"C:'Temp'keywords.txt");
List<string> nomatch = new List<string>();
System.Net.WebClient wc = new System.Net.WebClient();
foreach (string word in keywords)
{
string response = wc.DownloadString("http://www.website.com/search.php?word=" + word);
if (response != null && response.Contains("No matches found"))
nomatch.Add(word);
}
if (nomatch.Count > 0)
System.IO.File.WriteAllLines(@"C:'Temp'nomatch.txt", nomatch.ToArray());