private static bool ContainsEmbedOrObject(string html) { try { IElementPredicate predicate = new OrPredicate(new BeginTagPredicate("embed"), new BeginTagPredicate("object"), new BeginTagPredicate("iframe")); HtmlExtractor ex = new HtmlExtractor(html); return ex.Seek(predicate).Success; } catch { return false; } }
Size FindSizeAttribute(string input) { Size size = new Size(_width, _height); if (string.IsNullOrEmpty(input)) return size; try { RequiredAttribute[] attrWidth = new RequiredAttribute[] { new RequiredAttribute("width"), new RequiredAttribute("height") }; IElementPredicate predicate = new OrPredicate(new BeginTagPredicate("embed", attrWidth), new BeginTagPredicate("object", attrWidth)); HtmlExtractor ex = new HtmlExtractor(input); if (ex.Seek(predicate).Success) { BeginTag tag = (BeginTag)ex.Element; size = new Size(Convert.ToInt32(tag.GetAttributeValue("width"), CultureInfo.InvariantCulture), Convert.ToInt32(tag.GetAttributeValue("height"), CultureInfo.InvariantCulture)); } } catch (Exception ex) { Trace.Fail("Exception thrown while trying to find video size: " + ex); } return size; }
private static bool ContainsEmbed(string input) { IElementPredicate predicate = new OrPredicate(new BeginTagPredicate("embed"), new BeginTagPredicate("object")); HtmlExtractor ex = new HtmlExtractor(input); return ex.Seek(predicate).Success; }