1

I need to read ask/bid price from crytpocurrency market. but "Stale Element Error" occurred when market is too crowd.

I use facebook/php-webdirver, Selenium Stand Alone Server 3.9.1.jar and chromeDriver and PHP 7.1 .

this is my first try to select data:

$driver->findElements(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='bid-price']"));

and its the last one:

$driver->wait()->until(WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='bid-price']")));

First question is am I in a right way to get this rapidly changeable data (like stock market or cryptocurrencies market)? cryptocurrency BID-ASK tables screenshot - from Bitz Bitz Cryptocurrency live BID-ASK table

And the second one is why when i use below Code to avoid fatal Error, nothing happened and fatal Error occurred as always ?

try{
$asks = $driver->findElements(WebDriverBy::xpath("//tr[@class='price-level']//td[@class='ask-price']"));
}catch(StaleElementReferenceException $e)
{
echo 'Error Occurred';
}
masood vahid
  • 140
  • 1
  • 8
  • Do you have a an actual stack trace from the exception? Your catch is only catching the StaleElementReferenceException and not something *caused* by a stale element exception. The stale element exception usually only happens when you try to access/manipulate a property of the element, not find the element. – Charlie Jul 14 '19 at 22:37
  • what should i do now ? – masood vahid Jul 15 '19 at 08:07

1 Answers1

-1

Finally after spend more than a week on Php, i decided to change my way. I review other language approaches. Js was first in weekly downloads. i try to use Selenium-WebDriver library in first with more than 1.4 million weekly downloads. Ok but i could not use this. actually i didn't like it for personal reason! also the other famous JS web scraping library named 'WebDriverIO' was not that i wants!

i never use NodeJS and NPM before and i cant find Quick install or fast way to run it and being professional.

I try Python for second and results was Great :) there is very fast start, many readable document to find your goal and many person to answer your question in other hand Python syntax was too similar to Php and you can connect it MySQL as easy you ever done in Php.

Python 3.7 with Selenium for python helped me to finish my app under 10 hours ( include learning python from zero).

finally my app works like a charm and i'm really happy :) now i have and interface coded by HTML/JS(jQueryAjax) + Database Connection on the server to feed my fontend + Python Script to scrape and feel DB.

Try-Catch still not working in facebook/php-webdriver Php but who care now !

masood vahid
  • 140
  • 1
  • 8