humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
set_user_agent
set_user_agent($agent_string,$refresh=true); - задать строку user-agent (идентификатор браузера)Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Demonstrates how to set a custom user agent string to simulate different browsers or devices // Path to the init.php file for connecting to the XHE API $xhe_host = "localhost:7010"; if (!isset($path)){ // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // The following code demonstrates the usage of the set_user_agent function // First, get current user agent $current_ua = WEB::$browser->get_user_agent(); echo "Current user agent: " . $current_ua; // Set custom user agent $custom_ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"; $result = WEB::$browser->set_user_agent($custom_ua); // Display the result if ($result) { echo "\n\nSuccessfully set user agent to: " . $custom_ua; } else { echo "\n\nFailed to set user agent"; } // Verify the change $updated_ua = WEB::$browser->get_user_agent(); echo "\nUpdated user agent: " . $updated_ua; // Остановить работу WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7013" from xweb_human_emulator import * # начало echo("<hr><font color=blue>browser.xxxxxxxxx</font><hr>") # 1 if len(sys.argv)==1: echo("1. Получим юзерагент : ") echo(browser.get_user_agent(),"\n") # 2 echo("2. Зададим юзер агент (как у гугл бота) : ") echo(browser.set_user_agent("5Googlebot/2.1 (+http://www.google.com/bot.html)"),"<br>") sleep(5) app.restart(__file__,"1") if len(sys.argv)==2: # 3 echo("3. Перейдем на страницу, показывающую юзерагент : ") echo(browser.navigate("http://whoer.net"),"\n") # 4 echo("4. Получим юзерагент : ") echo(browser.get_user_agent(),"\n") sleep(5) app.restart(__file__,"1 2") if len(sys.argv)==3: # 5 echo("5. Вернем юзер агент : ") echo(browser.set_user_agent("Mozilla/4.0 (compatible) MSIE 7.0) Windows NT 6.0) WOW64) Trident/5.0) SLCC1) InfoPath.3)"),"<br>") sleep(5) app.restart(__file__,"1 2 3") # конец 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>browser.set_user_agent</font><hr>"); // 1 шаг echo("1. Получим юзер агент : "); echo(browser.get_user_agent()+"<br>"); // 2 шаг echo("2. Зададим юзер агент (как у гугл бота) : "); echo(browser.set_user_agent("3Googlebot/2.1 (+http://www.google.com/bot.html)")+"<br>"); // 2 шаг echo("3. Перейдем на страницу, показывающую юзерагент : "); echo(browser.navigate("http://whoer.net")); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:7010"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>browser.set_user_agent</font><hr>"); // 1 шаг echo("1. Получим юзерагент : "); echo(browser.get_user_agent()+"\n"); // 2 шаг echo("2. Зададим юзер агент (как у гугл бота) : "); echo(browser.set_user_agent("5Googlebot/2.1 (+http://www.google.com/bot.html)")+"<br>"); // 3 шаг echo("3. Перейдем на страницу, показывающую юзерагент : "); echo(browser.navigate("http://whoer.net")+"\n"); // 4 шаг echo("4. Получим юзерагент : "); echo(browser.get_user_agent()+"\n"); // 5 шаг echo("5. Вернем юзер агент : "); echo(browser.set_user_agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/5.0; SLCC1; InfoPath.3)")+"<br>"); // конец echo("\n"); // Quit app.quit();
=============================================
Browser Объекты DOM System Vision Web Window
=============================================
если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
.