CreateDocument() публичный статический Метод

Creates a new DOM from a stream containing HTML
public static CreateDocument ( System.Stream html ) : CQ
html System.Stream /// An open Stream ///
Результат CQ
Пример #1
0
        /// <summary>
        /// Creates a new DOM from an HTML file.
        /// </summary>
        ///
        /// <param name="htmlFile">
        /// The full path to the file
        /// </param>
        ///
        /// <returns>
        /// The new document from file.
        /// </returns>

        public static CQ CreateDocumentFromFile(string htmlFile)
        {
            using (Stream strm = Support2.GetFileStream(htmlFile))
            {
                return(CQ.CreateDocument(strm));
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new DOM from an HTML file.
        /// </summary>
        ///
        /// <param name="url">
        /// The URL of the remote server.
        /// </param>
        /// <param name="options">
        /// The options to use when creating the reqest.
        /// </param>
        ///
        /// <returns>
        /// A CQ object composed from the HTML response from the server.
        /// </returns>

        public static CQ CreateFromUrl(string url, ServerConfig options = null)
        {
            CsqWebRequest request = new CsqWebRequest(url);

            ServerConfig.Apply(options, request);

            request.Get();

            return(CQ.CreateDocument(request.Html));
        }
Пример #3
0
        /// <summary>
        /// Creates a new DOM from an HTML file.
        /// </summary>
        ///
        /// <param name="url">
        /// The URL of the remote server.
        /// </param>
        /// <param name="options">
        /// The options to use when creating the reqest.
        /// </param>
        ///
        /// <returns>
        /// A CQ object composed from the HTML response from the server.
        /// </returns>

        public static CQ CreateFromUrl(string url, ServerConfig options = null)
        {
            CsqWebRequest request = new CsqWebRequest(url);

            request.Options = options;

            var httpRequest    = request.GetWebRequest();
            var response       = httpRequest.GetResponse();
            var responseStream = response.GetResponseStream();
            var encoding       = CsqWebRequest.GetEncoding(response);

            return(CQ.CreateDocument(responseStream, encoding));
        }