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

问题描述

我正在尝试使用 scrapy 和 splash 解析网站的 HTML。我的主要 lua 函数返回语句看起来像 return splash:html() 然后我试图在我的 def parse(self,response) 函数中解析 HTML。但是,我所有的 response.css 和 response.xpath 都返回 None 和空列表。另外,我注意到 HTML 看起来很奇怪(包含几个 html 代码标签、json 对象、没有类、没有 id...)。我猜 splash:html() 不会像看起来像 HTML 的实际 response.body 那样返回。我可以看到文档提到了一个 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":

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)