简体   繁体   中英

Get data from table with PHP Simple HTML DOM Parser

I want to extract data that are in table #buyOrdersTable from here

https://bittrex.com/Market/Index?MarketName=BTC-XRP

To do this I am using PHP Simple HTML DOM Parser library and following code:

$html = file_get_html('https://bittrex.com/Market/Index?MarketName=BTC-XRP');

echo 'BTC/XRP<br>';

foreach($html->find('div.buy-table-container tr.dyn-tr-add td') as $td) 
{
    echo $td->plaintext . '<br>';
}

?>

I want to extract every row from BID section - SUM, TOTAL, SIZE (XRP), BID (BTC). But code doesn't find any row.

You can't do that. It's impossible, as explained by msg in the comments.

To do it properly, sign up for an API key, and call the API!

https://support.bittrex.com/hc/en-us/articles/115003723911-Developer-s-Guide-API

You'll probably want to use Guzzle, or cURL to make your requests. You can find lots of tutorials showing how to connect to any API using either.

This may or may not help you. A while back I started writing a library that hooked up to the BTC-e exchange (now Wex.nz). You can make adapters for any exchange, so you could tweak this code if you like.

https://github.com/delboy1978uk/BTCExchange/blob/master/src/Exchange/BtcE.php

Which extends this class https://github.com/delboy1978uk/BTCExchange/blob/master/src/Exchange/ExchangeAbstract.php

Credit to msg for bothering to check Packagist. There are many ready-to-rock Bittrex API packages waiting to be installed! https://packagist.org/?query=bitrex-api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM