humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | лог изменений

get_screenshot_path

get_screenshot_path($position); - получить путь к скриншоту, для заданного урла (урл на заданой позиции во входном файле)

Функция на вход принимает параметры:

  • $position – позиция урла во входном файле

    После отработки функция возвращает результат своей работы в скрипт :
  • путь к скриншоту сделанному для заданного урла

    Пример использования
    <?php
    $xhe_host = "localhost:7010";
    // + cef
    // подключим функциональные объекты, если еще не подключен
    if (!isset($path))
      $path="../../../Templates/init.php";
    require($path);
    
    // начало
    echo "\n<font color=blue>webpage->".basename (__FILE__)."</font>\n";
    
    // 1 
    echo "1. Сфорируем файл с урлами : ";
    $path="test/in_file.urls";
    echo SYSTEM::$file_os->delete("test/in_file.urls") . "\n";
    echo SYSTEM::$textfile->add_string_to_file("test/in_file.urls","ya.ru\n") . "\n";
    echo SYSTEM::$textfile->add_string_to_file("test/in_file.urls","google.com\n") . "\n";
    echo SYSTEM::$textfile->add_string_to_file("test/in_file.urls","yandex.ru\n") . "\n";
    echo SYSTEM::$textfile->add_string_to_file("test/in_file.urls","vk.com\n") . "\n";
    echo SYSTEM::$textfile->add_string_to_file("test/in_file.urls","ttttttt\n") . "\n";
    
    // 2
    echo "\n2. Инициализируем сборщик файлом с урлами: ";
    echo WEB::$harvestor->init("test/in_file.urls") . "\n";
    echo WEB::$harvestor->make_screenshots() . "\n";
    echo WEB::$harvestor->set_browser_size(2000,2000);
    
    // 3
    echo "\n3. Запуститм сбор и дождемся окончания : ";
    echo WEB::$harvestor->start(false)."\n";
    while (!WEB::$harvestor->is_finished())
    {
      sleep(1);
      echo "." . WEB::$harvestor->get_completed_count().".";
    }
    
    
    // 4
    echo "\n4. Выведем пути к скриншотам урлов из файла :\n ";
    $count = SYSTEM::$textfile->get_lines_count($path);
    for ($i=0;$i<$count;$i++)
      echo WEB::$harvestor->get_screenshot_path($i)."\n";
    
    // покажем один скриншот
    //WINDOW::$app->shell_execute("open", WEB::$harvestor->get_screenshot_path(2));
    
    // конец
    echo "\n";
    
    // Quit
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7012"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>ftp.xxxxxxxxx</font><hr>")
    
    # 1 
    echo("1. Сфорируем файл с урлами : ");
    path = "test/in_file.urls";
    echo(file_os.delete("test/in_file.urls")," ");
    echo(textfile.add_string_to_file("test/in_file.urls","ya.ru\n")," ");
    echo(textfile.add_string_to_file("test/in_file.urls","google.com\n")," ");
    echo(textfile.add_string_to_file("test/in_file.urls","yandex.ru\n")," ");
    echo(textfile.add_string_to_file("test/in_file.urls","vk.com\n")," ");
    echo(textfile.add_string_to_file("test/in_file.urls","ttttttt\n")," ");
    
    # 2
    echo("\n2. Инициализируем сборщик файлом с урлами: ");
    echo(harvestor.init("test/in_file.urls")," ");
    echo(harvestor.make_screenshots()," ");
    echo(harvestor.set_browser_size(1000,1000));
    
    # 3
    echo("\n3. Запуститм сбор и дождемся окончания : ");
    echo(harvestor.start(false),"<br>");
    while not harvestor.is_finished():
      echo("."+str(harvestor.get_completed_count())+".");
      sleep(1)
    
    # 4
    echo("\n4. Выведем пути к скриншотам урлов из файла : \n");
    count = textfile.get_lines_count(path);
    for i in range(0, count):
      echo(harvestor.get_screenshot_path(i),"\n")
    
    # покажем один скриншот
    app.shell_execute("open",harvestor.get_screenshot_path(1));
    
    # конец
    echo("<hr><br>")
    
    # Quit
    app.quit()
    #region using
    
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
    
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
    
    #endregion
    
     class Program:XHEScript
     {
    	  static void Main(string[] args)
    	  {
    			// init XHE
    			server = "localhost:7010";
    			InitXHE();
    
    			// начало
    			echo("<hr><font color=blue>harvest.get_screenshot_path</font><hr>");
    				
                // 1 
                echo("1. Сфорируем файл с урлами : ");
                string path="test\\in_file.urls";
                echo(file_os.delete("test/in_file.urls")+" ");
                echo(textfile.add_string_to_file("test\\in_file.urls","ya.ru\n")+" ");
                echo(textfile.add_string_to_file("test\\in_file.urls","google.com\n")+" ");
                echo(textfile.add_string_to_file("test\\in_file.urls","yandex.ru\n")+" ");
                echo(textfile.add_string_to_file("test\\in_file.urls","vk.com\n")+" ");
                echo(textfile.add_string_to_file("test\\in_file.urls","ttttttt\n")+" ");
    
                // 2
                echo("\n2. Инициализируем сборщик файлом с урлами: ");
                echo(harvestor.init("test\\in_file.urls")+" ");
                echo(harvestor.make_screenshots()+" ");
                echo(harvestor.set_browser_size(2000,4000));
    
                // 3
                echo("\n3. Запуститм сбор и дождемся окончания : ");
                echo(harvestor.start(false)+"<br>");
                while (!harvestor.is_finished())
                {
                  echo("."+harvestor.get_completed_count()+"."); 
                  sleep(1);
                }
    
                // 4
                echo("\n4. Выведем пути к скриншотам урлов из файла : \n");
                int count = textfile.get_lines_count(path);
                for (int i=0;i<count;i++)
                  echo(harvestor.get_screenshot_path(i)+"\n");
    
                // покажем один скриншот
                app.shell_execute("open",harvestor.get_screenshot_path(2));
    
    			
    			// конец
    			echo("\n\n");
    
    			app.quit();            
    	  }
    }
    // подключим функциональные объекты, если еще не подключен
    xhe_host="127.0.0.1:7012";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>harvestor.get_screenshot_path</font><hr>");
    
    // 1 
    echo("1. Сфорируем файл с урлами : ");
    path="test/in_file.urls";
    echo(file_os.delete("test/in_file.urls")+" ");
    echo(textfile.add_string_to_file("test/in_file.urls","ya.ru\n")+" ");
    echo(textfile.add_string_to_file("test/in_file.urls","google.com\n")+" ");
    echo(textfile.add_string_to_file("test/in_file.urls","yandex.ru\n")+" ");
    echo(textfile.add_string_to_file("test/in_file.urls","vk.com\n")+" ");
    echo(textfile.add_string_to_file("test/in_file.urls","ttttttt\n")+" ");
    
    // 2
    echo("\n2. Инициализируем сборщик файлом с урлами: ");
    echo(harvestor.init("test/in_file.urls")+" ");
    echo(harvestor.make_screenshots()+" ");
    echo(harvestor.set_browser_size(800,600)+" ");
    
    // 3
    echo("\n3. Запуститм сбор и дождемся окончания : ");
    echo(harvestor.start(false)+"<br>");
    while (!harvestor.is_finished())
      echo("."+harvestor.get_completed_count()+".");  
    
    // 4
    echo("\n4. Выведем пути к скриншотам урлов из файла : \n");
    count = textfile.get_lines_count(path);
    for (i=0;i<count;i++)
      echo(harvestor.get_screenshot_path(i)+"\n");
    
    // покажем один скриншот
    app.shell_execute("open",harvestor.get_screenshot_path(3));
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    Harvestor    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .