gpt4 book ai didi

python - Scrapy的HTMLXPathSelector在解析html页面时导致 'segmentation fault'

转载 作者:太空宇宙 更新时间:2023-11-03 19:18:22 25 4
gpt4 key购买 nike

发生“段错误”,scrapy 停止运行。检查网站网址后,我发现它应该属于一个标签href 属性但没有值。像这样:“<a href> dummy </a>”我怀疑这是由lxml .so lib引起的,如何处理?在至少可以防止蜘蛛停止问题。我的代码片段:

hxs = HtmlXPathSelector(response)
sites = hxs.select('//a')
for site in sites:
list_title= site.select('text()').extract()
list_link = site.select('./@href').extract() #????(crash here when parsing <a href></a>)

顺便说一句,被抓取的网站是“http://mil.news.sohu.com/”运行环境:scrapy 0.15.1和python 2.7.3,预装openssl0.12,因为scrapy默认的openssl0.13没有安装成功。

非常感谢亚伦

最佳答案

我已经解决了这个问题。这是由 scrapy 默认安装的 libxml2 版本 2.6.26 引起的。更新libxml2到2.7.4,解决。

关于python - Scrapy的HTMLXPathSelector在解析html页面时导致 'segmentation fault',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10611298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com