0
我想用jsdom從文章中獲取描述。 文章的HTML代碼jsdom獲取文本無圖像
<p><img src="http://localhost/bibi_cms/cms/app/images/upload_photo/1506653694941.png"
style="width: 599.783px; height: 1066px;"></p>
<p>testestestestestestestest<br></p>
這裏是我對的NodeJS從內容獲取描述代碼,看來它會得到第一p標籤的文本,打印出空字符串。所以我只想獲取不包含圖片的標記的內容p。任何人在這個問題上幫助我?
const dom = new JSDOM(results[i].content.toString());
if (dom.window.document.querySelector("p") !== null)
results[i].description = dom.window.document.querySelector("p").textContent;