欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

selenium部署-創(chuàng)新互聯(lián)

  1. 安裝selenium:
    composer  require  facebook/webdriver
  2. 下載jdk(略)
  3. 下載selenium服務(wù):
    https://goo.gl/FCSwwD
  4. 運(yùn)行selenium服務(wù):
    java  -jar  selenium-server-standalone-3.14.0.jar
  5. 下載chromedriver:
    https://chromedriver.storage.googleapis.com/2.9/chromedriver_win32.zip
  6. 將chromedriver放到chrome安裝目錄下:
    C:\Program Files (x86)\Google\Chrome\Application
  7. 移動(dòng)chromedriver到chrome安裝目錄:
    selenium部署
  8. 添加chrome安裝目錄下環(huán)境變量:
    selenium部署
  9. 編寫(xiě)測(cè)試代碼(test.php):

    阿克塞哈薩克族自治ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書(shū)銷(xiāo)售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書(shū)合作)期待與您的合作!
    <?php
    namespace Facebook\WebDriver;
    use Facebook\WebDriver\Remote\DesiredCapabilities;
    use Facebook\WebDriver\Remote\RemoteWebDriver;
    require_once('vendor/autoload.php');
    header("Content-Type: text/html; charset=UTF-8");
    $waitSeconds = 15;  //需等待加載的時(shí)間,一般加載時(shí)間在0-15秒,如果超過(guò)15秒,報(bào)錯(cuò)。
    $host = 'http://localhost:4444/wd/hub'; // this is the default
    $capabilities = DesiredCapabilities::chrome();
    $driver = RemoteWebDriver::create($host, $capabilities, 5000);
    $baseUrl = 'http://www.bilibili.com/';
    $driver->get($baseUrl);
    echo consoleText($driver->getTitle()) . "\n";    //cmd.exe中文亂碼,所以需轉(zhuǎn)碼
    $topLists = $driver->findElement(WebDriverBy::className('container-top-wrapper'))->findElement(WebDriverBy::className('top-list-wrapper'))->findElements(WebDriverBy::tagName('li'));
    foreach ($topLists as $topLi) {
    $itemContent = $topLi->findElement(WebDriverBy::tagName('a'));
    echo consoleText($itemContent->getAttribute('title')) . ' : ' . consoleText($itemContent->getAttribute('href')) . "\n";
    }
    //關(guān)閉瀏覽器
    $driver->quit();
    function consoleText($text, $pageEncoding = '', $consoleEncoding = '')
    {
    // windows
    if (!$consoleEncoding) {
        if (stristr(php_uname('s'), 'win')) {
            $consoleEncoding = "GBK";
        } else {
            $consoleEncoding = 'UTF-8';
        }
    }
    return exchangeEncoding($text, $pageEncoding, $consoleEncoding);
    }
    function exchangeEncoding($text, $pageEncoding = '', $targetEncoding = 'UTF-8')
    {
    if (!$pageEncoding) {
        $pageEncoding = mb_detect_encoding($text, array("ASCII", 'UTF-8', "GB2312", "GBK", 'BIG5'));
    }
    
    if ($pageEncoding != $targetEncoding) {
        return mb_convert_encoding($text,$targetEncoding,$pageEncoding);
    }
    
    return $text;
    }
    //切換至最后一個(gè)window
    function switchToEndWindow($driver)
    {
    
    $arr = $driver->getWindowHandles();
    foreach ($arr as $k => $v) {
        if ($k == (count($arr) - 1)) {
            $driver->switchTo()->window($v);
        }
    }
    }
  10. 運(yùn)行測(cè)試代碼:
    php  test.php

    selenium部署

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

標(biāo)題名稱(chēng):selenium部署-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)地址:http://chinadenli.net/article6/dojgig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化域名注冊(cè)、ChatGPT網(wǎng)站制作、網(wǎng)站策劃建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司