Search Results for

    Show / Hide Table of Contents

    Class Response

    Represents a http response made by IronWebScraper

    Inheritance
    System.Object
    Response
    Namespace: IronWebScraper
    Assembly: IronWebScraper.dll
    Syntax
    public class Response : Object

    Constructors

    Response()

    Declaration
    public Response()

    Fields

    CharSet

    Name of the charset used to encode the web resource. When reading TextConent, the result has already been decoded to C# default encoding (utf-8) on your behalf.

    Declaration
    public string CharSet
    Field Value
    Type Description
    System.String

    CretaedFromWebCache

    True if the Response was created from a cached version of the Url rather than from live data. See WebScraper.EnableWebCache() method, which is can be called from within the WebScraper.Init() method.

    Declaration
    public bool CretaedFromWebCache
    Field Value
    Type Description
    System.Boolean

    FinalUrl

    The Url from which the Response was returned. This may differ from RequestlUrl if these was an http redirect.

    Declaration
    public string FinalUrl
    Field Value
    Type Description
    System.String

    MimeType

    The MIME type of the Response content. E.g: "text/html"

    Declaration
    public string MimeType
    Field Value
    Type Description
    System.String

    Request

    The Request from which the Response was created.

    Declaration
    public Request Request
    Field Value
    Type Description
    Request

    StatusCode

    The http status code given by the url which as 200 or 404. 0 is returned in case the server is uncontactable.

    Declaration
    public int StatusCode
    Field Value
    Type Description
    System.Int32

    Properties

    BinaryContent

    The content downloaded from the Url as raw binary data

    Declaration
    public byte[] BinaryContent { get; }
    Property Value
    Type Description
    System.Byte[]

    Document

    Returns an HtmlNode for the entire Response Document. (HTML/XML)

    Declaration
    public HtmlNode Document { get; }
    Property Value
    Type Description
    HtmlNode

    Html

    Synonym of content which checks for an Html content

    Declaration
    public string Html { get; }
    Property Value
    Type Description
    System.String

    The HTML.

    Exceptions
    Type Condition
    System.FormatException

    Document does not have an HTML mime type or contain a <body> or <html> tag

    MetaData

    Returns additional meta-data which was attached to the Request.

    Declaration
    public MetaData MetaData { get; }
    Property Value
    Type Description
    MetaData

    RequestlUrl

    The Url from which the Response was requested. This may differ from FinalUrl if these was an http redirect.

    Declaration
    public string RequestlUrl { get; }
    Property Value
    Type Description
    System.String

    TextContent

    The content downloaded from the Url encoded as a String.

    Declaration
    public string TextContent { get; }
    Property Value
    Type Description
    System.String

    WasSuccessful

    Gets a value indicating whether this HTTP request yielded a successful response code.

    Declaration
    public bool WasSuccessful { get; }
    Property Value
    Type Description
    System.Boolean

    true if the response was successful; otherwise, false.

    Methods

    Css(String)

    Uses CSS selectors to find all matching nodes within the Response Document. This works in the same way as $('.ClassName') in jQuery or querySelectorAll() in JavaScript.

    Declaration
    public HtmlNode[] Css(string selector)
    Parameters
    Type Name Description
    System.String selector
    Returns
    Type Description
    HtmlNode[]

    CssExists(String)

    Uses CSS selectors to find if there are any matching nodes within the Response Document. This works in the same way as
    $('.ClassName').length > 0 in jQuery or querySelectorAll().length > 0 in JavaScript.

    Declaration
    public bool CssExists(string selector)
    Parameters
    Type Name Description
    System.String selector
    Returns
    Type Description
    System.Boolean

    GetElementById(String)

    Synonym of JavaScript's getElementById function. Searches inside the response as an HTML or XML Document by ID attribute.

    Declaration
    public HtmlNode GetElementById(string id)
    Parameters
    Type Name Description
    System.String id
    Returns
    Type Description
    HtmlNode

    GetElementsByTagName(String)

    Synonym of JavaScript's getElementById function. Searches inside the response as an HTML or XML Document by tag-name such as "a" or "img".

    Declaration
    public HtmlNode[] GetElementsByTagName(string tagName)
    Parameters
    Type Name Description
    System.String tagName
    Returns
    Type Description
    HtmlNode[]

    QuerySelector(String)

    Synonym of JavaScript's querySelector function. Searches inside the Response document as an HTML or XML Document using CSS selectors.

    Declaration
    public HtmlNode QuerySelector(string selector)
    Parameters
    Type Name Description
    System.String selector
    Returns
    Type Description
    HtmlNode

    QuerySelectorAll(String)

    Synonym of JavaScript's querySelectorAll function. Searches inside the response document as an HTML or XML Document using CSS selectors.

    Declaration
    public HtmlNode[] QuerySelectorAll(string selector)
    Parameters
    Type Name Description
    System.String selector
    Returns
    Type Description
    HtmlNode[]

    ToAbsoluteUrl(IEnumerable<String>)

    Makes any relative url strings absolute relative to this Response Document.

    Declaration
    public IEnumerable<string> ToAbsoluteUrl(IEnumerable<string> urls)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.String> urls
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.String>

    ToAbsoluteUrl(String)

    Makes a relative url strings absolute relative to this Response Document.

    Declaration
    public string ToAbsoluteUrl(string url)
    Parameters
    Type Name Description
    System.String url
    Returns
    Type Description
    System.String

    XPath(String)

    Searches inside the response as an HTML/XML Document using an XPath expression.

    Declaration
    public HtmlNode[] XPath(string expression)
    Parameters
    Type Name Description
    System.String expression
    Returns
    Type Description
    HtmlNode[]
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronWebscraper to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronWebscraper free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.