Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jsdom的多行属性_Javascript_Node.js_Web Scraping_Screen Scraping_Jsdom - Fatal编程技术网

Javascript 使用jsdom的多行属性

Javascript 使用jsdom的多行属性,javascript,node.js,web-scraping,screen-scraping,jsdom,Javascript,Node.js,Web Scraping,Screen Scraping,Jsdom,是否可以使用jsdom获取多行属性的值(我使用Node.js+JQuery) 要刮取的站点包括以下HTML: <li><a data-title="<strong>hello world this is a test</strong>" href="example.org</strong>">A link</a></li> 不幸的是,这会被解析为 <li><a data-title="da

是否可以使用jsdom获取多行属性的值(我使用Node.js+JQuery)

要刮取的站点包括以下HTML:

<li><a data-title="<strong>hello world
this is a test</strong>" href="example.org</strong>">A link</a></li>
  • 不幸的是,这会被解析为

    <li><a data-title="data-title"><strong>hello world
    this is a test</strong>' href="example.org">A link</a></li>
    
  • 因此我无法提取title和href属性,例如通过JQuery:
    $(“a”).attr(“数据标题”)


    有什么想法吗?

    是的,这是
    jsdom
    解析器中的一个bug。这是因为它没有使用完全兼容HTML5的解析器。您可以看到这些错误仍然没有解决:


  • 您可以尝试使用刮削功能。

    Cheerio似乎也被多行属性阻塞了:-/。我想我要换成机械化。