Reputation: 55
I am working on a program where I am copying links from gmail inbox and save it in a text file, the link that is copied also have some unwanted characters, and I want to get rid of those unwanted characters. please help.
here is my code.
Here is the function of copying links:
public void grabAuthentication()
{
HtmlElementCollection links = webBrowser4.Document.Links;
using (TextWriter tw = new StreamWriter("activation.txt", true))
{
foreach (HtmlElement link in links)
{
if (link.OuterHtml.Contains("https://example.com"))
{
tw.WriteLine(link.InnerHtml);
}
}
}
}
Firing the function on a button click :
private void button1_Click(object sender, EventArgs e)
{
grabAuthentication();
}
Example of links collected in textfile :
https://example.com/<WBR>verify/<WBR>y8sURA0egNgcaUyMlOapqQ8ehleNDv<WBR>L6Pu48Pkg0
https://example.com/<WBR>verify/<WBR>PtjKgpMuqeAchnvZus7nDCnJ6oKfdr<WBR>oFX1k8dIBSs
https://example.com/<WBR>verify/<WBR>xtojDKjbNzXWYKTDlTqmFmRZGRcXax<WBR>TvTEADaGQ
Now I want to remove from each line of textfile which occurs 3 times in each line.
Upvotes: 1
Views: 107
Reputation: 3781
String.Replace
may help you.
if (link.OuterHtml.Contains("https://example.com"))
{
tw.WriteLine(link.InnerHtml.Replace("<WBR>", null));
}
Upvotes: 2