は、私は、これは (https://www.google.com/search?q=myquery&num=100)Bing検索結果からURLを抽出する正規表現を作成する方法
@"(?<=<h3 class=\""r\""><a href=\""\/url\?q=)(.*?)(?=&)";
ここで私はGoogleからの各URLを抽出することができ、コードからGoogle検索の結果
const string regexPattern = @"(?<=<h3 class=\""r\""><a href=\""\/url\?q=)(.*?)(?=&)";
public static string[] TopUrls(string data)
{
Regex regex = new Regex(regexPattern);
MatchCollection collection = regex.Matches(data);
return collection.Cast<Match>()
.Select(m => m.Value)
.ToArray();
}
string downloadUrl = "https://www.google.com" + "https://stackoverflow.com/search?q=" + keyword.ToString() + "&num=" + numResults + "&as_qdr=all&ei=LrUVVf7UMrPfsAS7lICgCw&sa=N&biw=1440&bih=690";
fetch.Headers.Set(HttpRequestHeader.Host, "www.google.com");
string data = fetch.DownloadString(downloadUrl);
string[] results = TopUrls(data);
からURLを抽出するために私のコードのGoogleの検索結果からURLを抽出する必要があります検索結果。
ここでの結果です: ます。https:// WWWブロガーコム/プロフィール/ 15582992268736301561 ます。https:// WWWのブロガーコム/プロフィール/ 17377873899922361640
このURLのためにregexで書くためにどのように? http://www.bing.com/search?q=myquery&count=100
はありがとうございました:)
、例えばhttps://sourceforge.net/projects/myquery/files/myquery – userrrrrrr
私はあなたが正規表現を使ってhtmlを解析したいと思うと思います。 – aloisdg
Google検索の正規表現はすでにテストしていますか? – RokumDev