get_all_by_inner_html
get_all_by_inner_html($inner_html,$exactly=false,$frame="-1"); - Получить интерфейсы по внутреннему HTMLФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Get all elements by inner HTML from a collection // Description: This example demonstrates how to get a collection of elements and then find all elements with specific inner HTML within that collection // Classes used: XHEInterfaces, XHEDiv, XHEBrowser, XHEApplication // Connection string to XHE API $xhe_host = getenv("RPABOT_HOST_URL"); // Path to init.php file if (!isset($path)) { // Path to init.php file for connecting to XHE API $path = "../../../Templates/init.php"; // When connecting init.php file, all functionality of classes for working with XHE API will be available require($path); } // Navigate to the polygon page if the page was not loaded earlier WEB::$browser->navigate(TEST_POLYGON_URL . "divs.html"); // Example: Get all div elements and then find all divs with specific inner HTML within that collection // Get all div elements on the page $divs = DOM::$div->get_all(); // Check that we have found at least one div if ($divs->count() > 0) { echo "Found " . $divs->count() . " div elements\n"; // Try to find all divs with a specific inner HTML (exact match) $targetHtml = "<p>Example</p>"; $divsByHtml = $divs->get_all_by_inner_html($targetHtml, true); // Check if any divs with the specified inner HTML were found if ($divsByHtml->count() > 0) { echo "\nFound " . $divsByHtml->count() . " div elements with inner HTML '" . $targetHtml . "' (exact match):\n"; // Process each found div for ($k = 0; $k < $divsByHtml->count(); $k++) { $currentDiv = $divsByHtml->get($k); if ($currentDiv->is_exist()) { echo "\nDiv #" . ($k + 1) . " with inner HTML '" . $targetHtml . "':\n"; echo "Div ID: " . $currentDiv->get_id() . "\n"; echo "Div inner number: " . $currentDiv->inner_number . "\n"; } } } else { echo "\nNo div elements with inner HTML '" . $targetHtml . "' (exact match) found in the collection\n"; } // Try to find all divs with a partial inner HTML match $partialHtml = "Example"; $divsByPartialHtml = $divs->get_all_by_inner_html($partialHtml, false); // Check if any divs with the partial inner HTML were found if ($divsByPartialHtml->count() > 0) { echo "\nFound " . $divsByPartialHtml->count() . " div elements with partial inner HTML '" . $partialHtml . "':\n"; // Process each found div for ($k = 0; $k < $divsByPartialHtml->count(); $k++) { $currentDiv = $divsByPartialHtml->get($k); if ($currentDiv->is_exist()) { echo "\nDiv #" . ($k + 1) . " with partial inner HTML '" . $partialHtml . "':\n"; echo "Div ID: " . $currentDiv->get_id() . "\n"; echo "Div inner number: " . $currentDiv->inner_number . "\n"; echo "Full inner HTML: " . $currentDiv->get_inner_html() . "\n"; } } } else { echo "\nNo div elements with partial inner HTML '" . $partialHtml . "' found in the collection\n"; } } else { echo "No div elements found on the page\n"; } // Stop the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # начало echo("<hr><font color=blue>interfaces.xxxxxxxxx</font><hr>") # 1 echo("1. Перейдем на полигон : ") echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html"),"<br>") # 2 echo("2. Получить все ссылки : ") anchors=anchor.get_all() echo(anchors.get_count(),"<br>") # 3 echo("3. Получим href ссылок с html, содержащим ссылка : <br>") anchors_1=anchors.get_all_by_inner_html("ссылка") print(anchors_1.get_href()) # 4 echo("4. Получим href ссылок с html = Блог : <br>") anchors_2=anchors.get_all_by_inner_html("Блог",true) print(anchors_2.get_href()) # конец 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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); // начало echo("<hr><font color=blue>interfaces.get_all_by_inner_html</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. Получить все ссылки : "); XHEInterfaces anchors=anchor.get_all(); echo(anchors.get_count()+"<br>"); // 3 шаг echo("3. Получим href ссылок с хтмл, содержащим ссылка : \n\n"); XHEInterfaces anchors_1=anchors.get_all_by_inner_html("ссылка"); echo(anchors_1.get_href()); // 4 шаг echo("\n4. Получим href ссылок с хтмл = Блог : \n\n"); XHEInterfaces anchors_2=anchors.get_all_by_inner_html("Блог",true); echo(anchors_2.get_href()); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>interface.get_all_by_inner_html</font><hr>"); // 1 шаг echo("1. Перейдем на полигон : "); echo(browser.navigate("https://rpa-bot.ru/wiki/poligon/anchor.html")+"<br>"); // 2 шаг echo("2. Получить все ссылки : "); anchors=anchor.get_all(); echo(anchors.get_count()+"<br>"); // 3 шаг echo("3. Получим href ссылок с html, содержащим ссылка : \n\n"); anchors_1=anchors.get_all_by_inner_html("ссылка"); echo(anchors_1.get_href()); // 4 шаг echo("\n4. Получим href ссылок с html = Блог : \n\n"); anchors_2=anchors.get_all_by_inner_html("Блог",true); echo(anchors_2.get_href()); // конец echo("\n"); // Quit app.quit();
=============================================
Interfaces Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.