微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决从 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 举报,一经查实,本站将立刻删除。