Regexp with multiple lines
Mostra commenti meno recenti
Hello, I would like to use urlread and regexp to extract a specific number from the url. Part oftThe content of the url is:
<td class="text-right">1</td>
<td data-sort="Ethereum"><img src="https://s2.coinmarketcap.com/static/img/coins/16x16/1027.png" class="logo" alt="Ethereum"><a href="/currencies/ethereum/" class="market-name">Ethereum</a></td>
<td data-sort="ETH/USD"><a href="https://www.kraken.com" target="_blank">ETH/USD</a></td>
<td class="text-right" data-sort="41450600.0">
<span class="volume" data-usd="41450600.0" data-btc="4441.21" data-native="54539.6">
$41,450,600
</span>
</td>
<td class="text-right" data-sort="760.01">
<span class="price" data-usd="760.01" data-btc="0.0814309" data-native="760.01">
$760.01
</span>
</td>
<td class="text-right" data-sort="20.679496448"><span data-format-percentage data-format-value="20.679496448">20.68</span>%</td>
<td class="text-right ">Recently</td>
</tr>
<tr>
<td class="text-right">2</td>
<td data-sort="Bitcoin"><img src="https://s2.coinmarketcap.com/static/img/coins/16x16/1.png" class="logo" alt="Bitcoin"><a href="/currencies/bitcoin/" class="market-name">Bitcoin</a></td>
<td data-sort="BTC/EUR"><a href="https://www.kraken.com" target="_blank">BTC/EUR</a></td>
<td class="text-right" data-sort="36350300.0">
<span class="volume" data-usd="36350300.0" data-btc="3894.74" data-native="3905.16">
$36,350,300
</span>
</td>
<td class="text-right" data-sort="9308.28">
<span class="price" data-usd="9308.28" data-btc="0.997331" data-native="7839.6">
$9308.28
</span>
I would like to extract this content, that begins with the word Ethereum and finishes with the number 760.01:
Ethereum</a></td>
<td data-sort="ETH/USD"><a href="https://www.kraken.com" target="_blank">ETH/USD</a></td>
<td class="text-right" data-sort="41450600.0">
<span class="volume" data-usd="41450600.0" data-btc="4441.21" data-native="54539.6">
$41,450,600
</span>
</td>
<td class="text-right" data-sort="760.01">
<span class="price" data-usd="760.01" data-btc="0.0814309" data-native="760.01">
$760.01
I'm trying to use this code, but I don't know what expression to use:
urlKraken='https://coinmarketcap.com/exchanges/kraken/';
strC=urlread(urlKraken);
expression='';
[startIndex,endIndex] = regexp(strC,expression);
3 Commenti
Jan
il 10 Mag 2018
"... finishes with the number 760.01" - I see 4 occurrences of "760.01" in the shown snippet. Which one is the wanted one? "Etherum" can be found multiple times also.
Are coinmarketcap or kraken.com commercial services?
Damián
il 11 Mag 2018
Rik
il 11 Mag 2018
Then my answer below should do the trick. Added bonus is that it first finds the value as well. If that solves your question, please consider marking it as accepted answer, if not, please describe your remaining issues with that code.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!