1
votes

I think changes with Google Sheets is to blame. I have been using this query //table[@class='coupon']//a/@href with this web page https://smarkets.com/sport/football/europe-uefa-champions-league-2016-2017/coupon and IMPORTXML and it did work fine in Google Sheets. It still does work fine when I check using xPath helper on the webpage itself , but it does not now display the results in Google Sheets.

Keeps saying no data found.

1

1 Answers

0
votes

Short answer

Google servers can't reach the desired table due to a check made by the web page. If they were able to do this in the past, then this is due to a recent change on the source site.

Explanation

Update

Note: The previous answer content is moved down, due to some comments about it.

Overview

The page does a check before showing the target source code, if the check is successful, then the browser automatically redirects the user to the target source code, but Google servers are not reaching that code.

How do I conclude the above

Searching about user-agent and the Google Sheets import functions, I found

Error "The data could not be retrieved." with importData() function

It's a post on the forum for Docs on Google Products Help Forum. It doesn't have an answer but the OP mentioned that he used curl and shows the result which includes the user agent. So I tried http://onlinecurl.com/. Here is an excerpt

<body id="iuam" class="">
<div id="flexmad">
<h1>Checking your browser</h1>
<img role="presentation" id="center-image" src= removed-to-save-space>

<p>Please wait while we perform a quick security check. This should take no longer than 5 seconds.</p>
<noscript>
<p class="error">Please enable JavaScript to contiune.</p>
</noscript>
</div>
<div id="cf-check"><div class="cf-browser-verification cf-im-under-attack">
  <noscript><h1 data-translate="turn_on_js" style="color:#bd2426;">Please turn JavaScript on and reload the page.</h1></noscript>
  <div id="cf-content" style="display:none">
    <div>
      <div class="bubbles"></div>
      <div class="bubbles"></div>
      <div class="bubbles"></div>
    </div>
    <h1><span data-translate="checking_browser">Checking your browser before accessing</span> smarkets.com.</h1>
    <p data-translate="process_is_automatic">This process is automatic. Your browser will redirect to your requested content shortly.</p>
    <p data-translate="allow_5_secs">Please allow up to 5 seconds&hellip;</p>
  </div>
  <form id="challenge-form" action="/cdn-cgi/l/chk_jschl" method="get">
    <input type="hidden" name="jschl_vc" value="e682f28a4d346769bed1f10a12224954"/>
    <input type="hidden" name="pass" value="1474651532.013-aR/miMPEsh"/>
    <input type="hidden" id="jschl-answer" name="jschl_answer"/>
  </form>
</div>
</div>

</body>

Original answer

IMPORTXML only can import elements that are in the source code of the page, in this case, the tag <table class="coupon"> is shown so we could discard that the problem is due to content be loaded from another file.

Using //a/@href IMPORTXML returns several results but not from the table tag. IMPORTHTML and IMPORTDATA doesn't work either, so it's very likely that the host site is blocking the access to some parts of the content, in this case to the desired table, to the Google servers.

I don't know yet how this can be done, but I think that it's related to the site robots.txt:

user-agent: sitebot
disallow: /

user-agent: AhrefsBot
disallow: /

User-agent: MJ12bot
Disallow: /

User-agent: *
Disallow: /account/withdraw/
Disallow: /account/deposit/
Disallow: /account/limits/
Disallow: /sport/market-aggregates

References

robots.txt - Wikipedia