0

I am running a Google Sheet and I want to extract the price of Bitcoin from a site called CoinMarketCap. The site is quite simple as is mainly a listing, and have a table full of different cryptocurrencies with price, marketcap and charts.

I am currently using the following url to import: https://coinmarketcap.com/currencies/bitcoin/

I am invoking the class: cmc-details-panel-price__price

The HTML snippet is like this:

<div class="cmc-details-panel-price jta9t4-0 deruLz"><span><span class="cmc-details-panel-price__price">$6,047.55</span><span class="cmc-details-panel-price__currency"> USD</span></span><span class="cmc--change-positive cmc-details-panel-price__price-change"> (13.79%)</span>
    <br><span class="cmc-details-panel-price__crypto-price">1.00000000 BTC</span><span class=""> (0.00%)</span>
    <div class="cmc-details-panel-toolbar-buttons sc-3v87nd-0 wTSaH">
        <a class="cmc-add-this-toolbar-button addthis_button_compact sc-2rs00z-0 csnKXq cmc-toolbar-button wbroff-0 cMpMbL at300m" href="#">
            <div class="cmc-toolbar-button__trigger"><span class="cmc-icon__wrap Icon__StyledIcon-sc-1pqyw27-0 bIZfMk"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="share-alt" class="svg-inline--fa fa-share-alt fa-w-14 cmc-icon" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M352 320c-22.608 0-43.387 7.819-59.79 20.895l-102.486-64.054a96.551 96.551 0 0 0 0-41.683l102.486-64.054C308.613 184.181 329.392 192 352 192c53.019 0 96-42.981 96-96S405.019 0 352 0s-96 42.981-96 96c0 7.158.79 14.13 2.276 20.841L155.79 180.895C139.387 167.819 118.608 160 96 160c-53.019 0-96 42.981-96 96s42.981 96 96 96c22.608 0 43.387-7.819 59.79-20.895l102.486 64.054A96.301 96.301 0 0 0 256 416c0 53.019 42.981 96 96 96s96-42.981 96-96-42.981-96-96-96z"></path></svg></span><span>Share</span></div>
        </a>
        <div class="cmc-watch-toolbar-button fzq4op-0 iJbRHV cmc-tooltip o711au-0 jVdtvL">
            <div class="cmc-popover sc-12d77vg-0 jIQcLK">
                <div class="cmc-popover__trigger">
                    <a class="cmc-toolbar-button wbroff-0 cMpMbL" data-qa-id="button-watch-unwatch">
                        <div class="cmc-toolbar-button__trigger"><span class="cmc-icon__wrap Icon__StyledIcon-sc-1pqyw27-0 bIZfMk"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="star" class="svg-inline--fa fa-star fa-w-18 cmc-icon" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"></path></svg></span><span>Watch</span></div>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

But still get an Error from the page. Formula looks like this: =IMPORTXML(H1,"//span[@class='cmc-details-panel-price__price’]")

Error: Imported XML content cannot be parsed.

  • I used Chrome Dev Tools (F12) to get the full XPath = /html/body/div[1]/div/div[2]/div[1]/div[2]/div[1]/div/div[1]/span[1]/span[1], then substituted it in your formula. It calculates Ok. – Tedinoz yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.