tags:

views:

57

answers:

1

I am having some issues with matching text to extract data from an HTML page. Here is what I have so far, but plainText stays empty:

private void Scrape()
{
  // create variables
  string html;
  string plainText;

  // download page source
  // sample URL: http://freekeywords.wordtracker.com/?seed=test&adult_filter=remove_offensive&suggest=Hit+Me";
  html = webBrowser1.Document.Body.InnerText; 

  // scrape keywords
  plainText = Regex.Match(html, @"class='k'[^x]display: none""", RegexOptions.IgnoreCase).Groups[1].Value;

  //plainText = Regex.Replace(plainText, @"\,", Environment.NewLine);
  //plainText = Regex.Replace(plainText, @"""", "");

  this.richTextBox1.Text = html;
}
A: 

You try to get value from group with index 1, but your regex does not contains any groups. User groups[0], or simply Match.Value.

necrostaz
by the way, i doubt that your html really contains code fragment similar 'k[not x]display: none"
necrostaz