response.body() 从 Splash 返回的 html() 看起来不像 HTML

我正在使用 scrapy 和 splash 解析网站的 HTML。我的主要 lua 函数的返回语句类似于 return splash:html(),然后我试图在我的 def parse(self, response) 函数中解析 HTML。然而,所有的 response.css 和 response.xpath 都返回 None 和空列表。另外,我注意到 HTML 看起来很奇怪(包含几个 html 代码标记、json 对象,没有类别,没有标识符……)。我猜想 splash:html() 并没有像实际的 response.body 那样返回 HTML。我看到文档提到了一个 lua 二进制对象,必须以某种方式转换为 lua 字符串,但对我来说这并不起作用。 类似以下内容:

<!DOCTYPE html><html lang="es" class="theme theme--mercado"><head>
    <script type="application/javascript">!function(i,n){void 0!==i.addEventListener&&void 0!==i.hidden&&(n.liVisibilityChangeListener=function(){i.hidden&&n.liHasWindowHidden=!0},i.addEventListener("visibilitychange",n.liVisibilityChangeListener))}(document,window);</script>
    <title>Title</title>
<link rel="stylesheet" href="https://static-exp1.licdn.com/sc/h/c36v9h7vs5uekvaupu8c54vij">
<meta name="__init" content="{&quot;routingLix&quot;:{&quot;engines&quot;:{&quot;profile&quot;:{&quot;lixKey&quot;:&quot;voyager.web.profile-tetris&quot;,&quot;lixedEngine&quot;:
[{"sourceType":"PROFILE_PICTURE","*miniProfile":"urn:li:fs_miniProfile:ACoAACngMAEBuHRFEFa9VFBZIh_f3zof_DiuAcA","$type":"com.voyager.common.ImageAttribute"}],"$type":"com.voyager.common.ImageViewModel"},"supplementaryActorInfo":{"textDirection":"USER_LOCALE","text":" • 3er y demás","$type":"com.voyager.common.TextViewModel"},"name":{"textDirection":"FIRST_STRONG","attributes":

点赞