public virtual TypedForm <T> Scrape <T>(string documentUrl) { var method = _element.AttributeOrEmpty("method"); var action = _element.AttributeOrEmpty("action"); if (string.IsNullOrWhiteSpace(action)) { action = documentUrl; } var form = new TypedForm <T>(_element, method, action); AddInputs(form); return(form); }
protected virtual bool IsSubmit(ElementWrapper formInput) { var tagName = formInput.TagName.ToLower(); var type = formInput.AttributeOrEmpty("type").ToLower(); return(tagName == "button" || (tagName == "input" && (type == "submit" || type == "image"))); }
public static FormValue FromElement(ElementWrapper element) { var formValue = new FormValue(element.AttributeOrEmpty("name")); formValue.SetDisabled(element.HasAttribute("disabled")); switch (element.TagName.ToLower()) { case "input": return(FromInput(element, formValue)); case "textarea": return(FromTextArea(element, formValue)); case "select": return(FromSelect(element, formValue)); default: throw new Exception("Unhandled tag: " + element.TagName); } }