简答
由于网页进行了检查,Google 服务器无法访问所需的表。如果他们过去能够做到这一点,那么这是由于源站点最近发生了变化。
说明
更新
注意:之前的回答内容下移了,因为有一些相关的内容。
概述
页面在显示目标源代码之前会进行检查,如果检查成功,则浏览器会自动将用户重定向到目标源代码,但 Google 服务器无法访问该代码。
我如何得出上述结论
搜索用户代理和谷歌表格导入功能,我发现
Error "The data could not be retrieved." with importData() function
这是 Docs on Google 产品帮助论坛论坛上的帖子。它没有答案,但 OP 提到他使用 curl 并显示了包含用户代理的结果。所以我尝试了http://onlinecurl.com/。这是一段摘录
<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…</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>
原答案
IMPORTXML 只能导入页面源代码中的元素,在这种情况下,会显示标签<table class="coupon">,因此我们可以忽略问题是由于从另一个文件加载内容引起的。
使用//a/@href IMPORTXML 会返回多个结果,但不是来自 table 标记。 IMPORTHTML 和 IMPORTDATA 也不起作用,因此很可能是主机站点阻止了对内容的某些部分的访问,在这种情况下是对所需表的访问,以及对 Google 服务器的访问。
我还不知道如何做到这一点,但我认为它与网站 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
参考文献
robots.txt - Wikipedia