I am having a problem with scraping this:
<td class="main txt"><a href="http://bors-nliv.svd.se/index.php/detail/index/4600">Afarak Group</a></td>
I would like to scrap the name of the stock, in this example its: Afarak Group but couldn't figure out how after all my attempts and searching. But I've managed to scrap of the stock prices with this code:
private void button3_Click(object sender, EventArgs e)
{
List<string> aktier = new List<string>();
WebClient web = new WebClient();
String html = web.DownloadString("http://bors-nliv.svd.se/index.php/aktier/index/35244");
MatchCollection m1 = Regex.Matches(html, @"<td>\s*(.+?)s*</td>", RegexOptions.Singleline);
foreach (Match m in m1)
{
if (m.Groups[1].Value != "3")
if (m.Groups[1].Value != "Aktier")
{
string aktie = m.Groups[1].Value;
aktier.Add(aktie);
}
}
listBox2.DataSource = aktier;
}
}
Here the stock price that only has this two htmltags
<td>0,41</td>
But how do I scrap the stocks name of the page when it looks like this?
<pre lang="HTML">
<td class="main txt"><td class="main txt"><a href="http://bors-nliv.svd.se/index.php/detail/index/4600">Afarak Group</a></td>
it's a couple more html tags.
I've tried to set the matches to this
MatchCollection m1 = Regex.Matches(html, @"<a href"">\s*(.+?)s*</td>", RegexOptions.Singleline);
But it still doesn't work. What am I missing?
What I have tried:
MatchCollection m1 = Regex.Matches(html, @"<a href"">\s*(.+?)s*</td>", RegexOptions.Singleline);