鍍金池/ 問答/Java  HTML/ 正則如何從html字符串里得到網(wǎng)站描述呢?

正則如何從html字符串里得到網(wǎng)站描述呢?

<meta name="description" content="在線開發(fā)Web前端代碼,在線測試ES6代碼,在線查找HTML5和CSS3實(shí)例代碼"> 

已經(jīng)有html 內(nèi)容了。
正則怎么寫才能得到content 呢?

希望通用一點(diǎn),對任何網(wǎng)站都適用。

回答
編輯回答
伴謊

[<].*content="(.*)".*[>]
$1 就可以取到content 的值

圖片描述

2017年7月21日 21:08
編輯回答
兔囡囡

clipboard.png

懶惰匹配:.*?

2018年7月29日 01:09
編輯回答
情殺

寫過爬蟲的就知道,有很多包都能解決這個(gè)問題, 給你推薦一個(gè)我最常用的包 cheerio

https://github.com/cheeriojs/...

2017年12月30日 07:07
編輯回答
近義詞
var Meta = $('meta[name="description"]').attr('content');
2017年10月26日 00:14