如何处理 php-webdriver 中 "stale element reference: element is not attached to the page document" 错误中的致命错误?
How handle fatal error in "stale element reference: element is not attached to the page document" error in php-webdriver?
我需要从加密货币市场读取 ask/bid 价格。但是 "Stale Element Error" 发生在市场太拥挤的时候。
我使用 facebook/php-webdirver、Selenium 独立服务器 3.9.1.jar 和 chromeDriver 以及 PHP 7.1。
这是我第一次尝试 select 数据:
$driver->findElements(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='bid-price']"));
最后一个:
$driver->wait()->until(WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='bid-price']")));
第一个问题是我是否以正确的方式获取这些快速变化的数据(如股票市场或加密货币市场)?
cryptocurrency BID-ASK tables screenshot - from Bitz
Bitz Cryptocurrency live BID-ASK table
第二个是为什么当我使用下面的代码来避免致命错误时,什么也没有发生,致命错误一如既往地发生?
try{
$asks = $driver->findElements(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='ask-price']"));
}catch(StaleElementReferenceException $e)
{
echo 'Error Occurred';
}
在 Php 上花了一个多星期后,我终于决定改变我的方式。
我回顾了其他语言方法。
Js 在每周下载量中排名第一。
我首先尝试使用 Selenium-WebDriver 库,每周下载量超过 140 万次。好的,但我无法使用它。其实我个人原因不喜欢它!
另一个名为 'WebDriverIO' 的著名 JS 网络抓取库也不是我想要的!
i never use NodeJS and NPM before and i cant find Quick install or fast way to run it and being professional.
我第二次尝试 Python,结果很棒 :)
启动非常快,许多可读文档可以找到您的目标,并且很多人可以回答您的问题 Python 语法与 Php 太相似了,您可以将它连接起来 MySQL 一样容易你曾在 Php.
做过
Python 3.7 with Selenium for python 帮助我在 10 小时内完成了我的应用程序(包括从零开始学习 python)。
终于,我的应用程序运行起来非常棒,我真的很高兴 :)
现在我有了 HTML/JS(jQueryAjax) 编码的界面
+ 服务器上的数据库连接以提供我的字体
+ Python 抓取和感受 DB 的脚本。
Try-Catch still not working in facebook/php-webdriver Php but who care now !
我需要从加密货币市场读取 ask/bid 价格。但是 "Stale Element Error" 发生在市场太拥挤的时候。
我使用 facebook/php-webdirver、Selenium 独立服务器 3.9.1.jar 和 chromeDriver 以及 PHP 7.1。
这是我第一次尝试 select 数据:
$driver->findElements(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='bid-price']"));
最后一个:
$driver->wait()->until(WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='bid-price']")));
第一个问题是我是否以正确的方式获取这些快速变化的数据(如股票市场或加密货币市场)? cryptocurrency BID-ASK tables screenshot - from Bitz Bitz Cryptocurrency live BID-ASK table
第二个是为什么当我使用下面的代码来避免致命错误时,什么也没有发生,致命错误一如既往地发生?
try{
$asks = $driver->findElements(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='ask-price']"));
}catch(StaleElementReferenceException $e)
{
echo 'Error Occurred';
}
在 Php 上花了一个多星期后,我终于决定改变我的方式。 我回顾了其他语言方法。 Js 在每周下载量中排名第一。 我首先尝试使用 Selenium-WebDriver 库,每周下载量超过 140 万次。好的,但我无法使用它。其实我个人原因不喜欢它! 另一个名为 'WebDriverIO' 的著名 JS 网络抓取库也不是我想要的!
i never use NodeJS and NPM before and i cant find Quick install or fast way to run it and being professional.
我第二次尝试 Python,结果很棒 :) 启动非常快,许多可读文档可以找到您的目标,并且很多人可以回答您的问题 Python 语法与 Php 太相似了,您可以将它连接起来 MySQL 一样容易你曾在 Php.
做过Python 3.7 with Selenium for python 帮助我在 10 小时内完成了我的应用程序(包括从零开始学习 python)。
终于,我的应用程序运行起来非常棒,我真的很高兴 :) 现在我有了 HTML/JS(jQueryAjax) 编码的界面 + 服务器上的数据库连接以提供我的字体 + Python 抓取和感受 DB 的脚本。
Try-Catch still not working in facebook/php-webdriver Php but who care now !