Scraping search results links from 1st page of bing.com in c#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="color:#333333; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; font-size:13px; line-height:16px
<p style=" I am tried to scrap search results links from 1st page. But it is giving an error. if you help i am very thank full to you. My code is
<p style="
<p style=" class Program
<p style=" {
<p style=" static void Main(string[] args)
<p style=" {
<p style=" ArrayList a = new ArrayList();
<p style=" byte[] aRequestHTML;
<p style=" WebClient objWebClient = new WebClient();
<p style=" string url="http://www.bing.com/search?q=hello&go=&qs=n&sk=&form=QBLH";
<p style=" aRequestHTML = objWebClient.DownloadData(url);
<p style="
<p style=" UTF8Encoding utf8 = new UTF8Encoding();
<p style=" string myString = utf8.GetString(aRequestHTML);
<p style=" Regex r = new Regex("href\s*=\s*(?:(?:\"(?[^\"]*)\")|(?[^\s]* ))");
<p style=" MatchCollection mcl = r.Matches(myString);
<p style="
<p style=" foreach (Match ml in mcl)
<p style=" {
<p style=" foreach (Group g in ml.Groups)
<p style=" {
<p style=" string b = g.Value + "";
<p style=" a.Add(b);
<p style=" }
<p style=" }
<p style="
<p style="
<p style=" for (int i = 0; i < a.Count; i++)
<p style=" {
<p style=" Console.WriteLine(a[0]);
<p style=" Console.ReadLine();
<p style=" }
<p style=" }
<p style=" }
<p style=" But it exception at Regex. Help me. Exception is parsing "hrefs*=s*(?:(?:"(?[^"]*)")|(?[^s]* ))" - Unrecognized grouping construct.(Argument Exception is un handled
<p style=" Thanks,
<p style=" Raufee


View the full article
 
Back
Top