Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string Cleanup(string d)
- {
- string df = @"
- <span>
- <style>
- .uvkn{display:none}
- .LHCZ{display:inline}
- .a8eg{display:none}
- .QKiO{display:inline}
- .rHiv{display:none}
- .kNWu{display:inline}
- .BnL8{display:none}
- .Z6Pm{display:inline}
- </style>
- <span></span>
- <span class=""kNWu"">94</span>
- <span class=""79"">.</span>
- <span></span>
- <span class=""rHiv"">126</span>
- <div style=""display:none"">126</div>
- <span class=""LHCZ"">198</span>
- <span class=""173"">.</span>
- <span></span>
- <span style=""display: inline"">34</span>
- <span style=""display:none"">37</span>
- <div style=""display:none"">186</div>
- <span class=""213"">.</span>
- <div style=""display:none"">23</div>
- <span class=""rHiv"">213</span>
- <span></span>230</span>";
- HtmlAgilityPack.HtmlNode node = HtmlNode.CreateNode(df);
- var te = node.SelectSingleNode("//style");
- string t = te.InnerText;
- List<string> hid = new List<string>();
- foreach (var s in t.Split(new string[]{"\r\n"},StringSplitOptions.RemoveEmptyEntries))
- {
- string name = s.Substring(1,4);
- string attr = s.Substring(6, s.Length - 7);
- if(attr.Contains("none"))
- hid.Add(name);
- }
- var rootNode = te.ParentNode;
- string result = string.Empty;
- foreach (HtmlNode n in rootNode.ChildNodes)
- {
- if (n.Attributes != null &&
- n.Attributes.Contains("style") &&
- n.Attributes["style"].Value.Contains(":none")
- )
- {
- continue;
- }
- if (n.Attributes!=null &&
- n.Attributes.Contains("class")&&
- hid.Contains(n.Attributes["class"].Value))
- {
- continue;
- }
- if(n.Name == "style" )
- continue;
- result += n.InnerText;
- }
- return result.Replace("\r\n","");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement