Class ScraperHelper
Some static utility methods for screen scrapers.
public static class ScraperHelper
- Inheritance
-
ScraperHelper
- Inherited Members
Methods
ScrapeAttribute(string, string, string)
public static string ScrapeAttribute(string sHtml, string sTag, string sValueAttribute)
Parameters
sHtmlstringsTagstringThe XML tag of the element that shall be scraped.
sValueAttributestringThe name of the attribute which's value shall be returned.
Returns
ScrapeAttribute(string, string, string, string, string)
public static string ScrapeAttribute(string sHtml, string sTag, string sName, string sNameAttribute, string sValueAttribute)
Parameters
sHtmlstringsTagstringThe XML tag of the element that shall be scraped.
sNamestringThe content of an attribute of that element that identifies it.
sNameAttributestringThe name of the attribute that shall contain sName.
sValueAttributestringThe name of the attribute which's value shall be returned.
Returns
ScrapeElement(string, string)
public static string ScrapeElement(string sHtml, string sTag)
Parameters
Returns
ScrapeElement(string, string, string, string, bool)
Scrape the content of an element with a given tag and attribute value.
public static string ScrapeElement(string sHtml, string sTag, string sAttribute, string sValue, bool fOuterHtml = false)
Parameters
sHtmlstringsTagstringsAttributestringThe attribute name of an attribute that must be contained in the tag.
sValuestringThe value of the required attribute.
fOuterHtmlbool
Returns
ScrapeElementByClassname(string, string, string, bool)
public static string ScrapeElementByClassname(string sHtml, string sTag, string sClassname, bool fOuterHtml = false)
Parameters
sHtmlstringsTagstringsClassnamestringThe name of a CSS class that must appear in the class attribute of the element.
fOuterHtmlbool
Returns
ScrapeElementByPosition(string, string, int, bool)
Returns the content of the n'th occurence of an element with a given tag.
public static string ScrapeElementByPosition(string sHtml, string sTag, int nPos, bool fOuterHtml = false)
Parameters
Returns
ScrapeElementByPosition(string, string, string, string, int, bool)
Scrape the content of an element with a given tag and attribute value.
public static string ScrapeElementByPosition(string sHtml, string sTag, string sAttribute, string sValue, int nPos, bool fOuterHtml = false)
Parameters
sHtmlstringsTagstringsAttributestringThe attribute name of an attribute that must be contained in the tag.
sValuestringThe value of the required attribute.
nPosintfOuterHtmlbool
Returns
ScrapeFormAction(string, string, string)
Extracts the action attribute value of a given form.
public static string ScrapeFormAction(string sHtml, string sFormName, string sNameAttribute = "name")
Parameters
sHtmlstringForm or complete page with holds form.
sFormNamestringName of the form.
sNameAttributestringThe attribute that contains the name of the form. By default this is the "name" attribute, but another attribute, e.g. "id" may be given here.
Returns
ScrapeFormParams(out string, string, string, string)
Extracts action attribute and all available input parameters from given form.
public static UrlQueryParams ScrapeFormParams(out string sFormAction, string sHtml, string sFormName, string sNameAttribute = "name")
Parameters
sFormActionstringReturns the form action.
sHtmlstringForm or complete page with holds form.
sFormNamestringName of the form.
sNameAttributestringThe attribute that contains the name of the form. By default this is the "name" attribute, but another attribute, e.g. "id" may be given here.
Returns
- UrlQueryParams
Returns all available input parameters of the form to be used as HTTP post or get query parameters.
ScrapeInputValue(string, string)
Extracts the value of the first occurence of a named input field.
public static string ScrapeInputValue(string sHtml, string sInputName)
Parameters
Returns
ScrapeInputValues(string, string)
Extracts all values of all occurences of a named input field.
public static string[] ScrapeInputValues(string sHtml, string sInputName)
Parameters
Returns
- string[]
ScrapeLink(string, string, string)
public static string ScrapeLink(string sHtml, string sLinkName, string sNameAttribute = "id")
Parameters
sHtmlstringsLinkNamestringsNameAttributestringThe attribute that contains the name of the link. By default this is the "id" attribute, but another attribute, e.g. "class" may be given here.
Returns
ScrapeLinkContaining(string, string)
Scrape the href of an anchor that contains the given string in its element content.
public static string ScrapeLinkContaining(string sHtml, string sContains)
Parameters
Returns
ScrapeValue(string, string)
public static string ScrapeValue(string sHtml, string sRegex)
Parameters
Returns
- string
Resulting match of the first regex group.