Beispiel #1
0
        public void Test_GetDocumentImagesByUrl_1()
        {
            var url = testUrls[2];

            var response = HtmlApi.GetDocumentImagesByUrl(url);

            checkGetMethodResponse(response, "Document", "_url_images");
        }
        public void Run()
        {
            var url  = "http://www.sukidog.com/jpierre/strings/basics.htm";
            var name = "basics.htm";

            IDocumentApi docApi = new HtmlApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            // call SDK method that gets a zip archive with all HTML document images
            var response = docApi.GetDocumentImagesByUrl(url);

            if (response != null && response.ContentStream != null && response.Status == "OK")
            {
                Stream stream  = response.ContentStream;
                string fname   = response.FileName;
                string outFile = fname ?? $"{name}_images.zip";
                string outPath = Path.Combine(CommonSettings.OutDirectory, outFile);
                using (FileStream fstr = new FileStream(outPath, FileMode.Create, FileAccess.Write))
                {
                    stream.Position = 0;
                    stream.CopyTo(fstr);
                    fstr.Flush();
                    Console.WriteLine(string.Format("\nResult file downloaded to: {0}", outPath));
                }
            }
        }