Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.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 如何提取child';使用jquery创建文本数据?_Javascript_Jquery_Html_Web Crawler_Phpquery - Fatal编程技术网

Javascript 如何提取child';使用jquery创建文本数据?

Javascript 如何提取child';使用jquery创建文本数据?,javascript,jquery,html,web-crawler,phpquery,Javascript,Jquery,Html,Web Crawler,Phpquery,我想从下面给出的html中提取数据“AT401726” <td class="publicationInfoColumn"> <h4>Publication info:</h4> AT401726<br>2008-08-15 </td> ('body').find('.publicationInfoColumn').clone().children().remove().end().text() 有没有其他更好的技术从上述h

我想从下面给出的html中提取数据“AT401726”

<td class="publicationInfoColumn">
  <h4>Publication info:</h4>
  AT401726<br>2008-08-15
</td>
('body').find('.publicationInfoColumn').clone().children().remove().end().text()
有没有其他更好的技术从上述html中提取数据?在我的已爬网html页面中有许多类似于上面的html使用:

$('td.publicationInfoColumn').text();//for text


您要查找的文本包含h4元素的下一个同级元素的内容,请尝试

var text = $.trim($('.publicationInfoColumn h4').prop('nextSibling').nodeValue);
console.log(text)
演示:

您不应该以这样的特定文本节点为目标。您可能能做的最好的事情是:

$('.publicationInfoColumn').html().match(/\b.*(?=<br>)/)
$('.publicationInfoColumn').html().match(/\b.*(=
)/)
html将包含标题,但OVE代码将提供>>发布信息:AT4017262008-08-15,但我只想要AT401726
$('.publicationInfoColumn').html().match(/\b.*(?=<br>)/)