D
D
Dmitriy2019-08-24 23:57:14
PHP
Dmitriy, 2019-08-24 23:57:14

How to speed up parsing with phpQuery?

require_once('../phpQuery/phpQuery.php');
  require_once('../curl.php');


  $curl = new Curl();
  $links = array(
    "http://www.binance.com/ru/trade/ZEC_BTC",
    "http://www.binance.com/ru/trade/ETH_BTC",
    "http://www.binance.com/ru/trade/DASH_BTC",
    "http://www.binance.com/en/trade/BCHABC_BTC",
    "http://www.binance.com/en/trade/ETC_BTC",
    "http://www.binance.com/en/trade/XRP_BTC",
    "http://www.binance.com/en/trade/DOGE_BTC"
  );
  $curr = array(
    "ZEC_BTC",
    "ETH_BTC",
    "DASH_BTC",
    "BCHABC_BTC",
    "ETC_BTC",
    "XRP_BTC",
    "DOGE_BTC"
  );
for( $i = 0; $i < count($links); $i++){
        $res = $curl->get($links[$i]);
        $doc = phpQuery::newDocument($res->body);
        $block = $doc->find('div.sc-62mpio-0.sc-1yysggs-2.kEGjPf');
        $block = str_replace("–","", $block);
        echo "<tr>";
        echo "<td>".$curr[$i]."</td>";
        echo "<td>".$block."</td>";
        echo "</tr>";
      }

How to make it parse faster?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2019-08-25
@dmitriyuvin

It is likely that the bottleneck here is curl requests, try the answers from this stackoverflow thread

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question