I have problem with parse html code on cheerio
Here's the code what i'm need to parse
<dd style="">
<p><strong>Version: </strong>0.4.0 (3612) for Android 4.3+ (Jelly Bean MR2, API 18)</p>
<p><strong>Update on: </strong>2018-04-17</p>
<p><strong>Signature: </strong>3ec8cd69d71b7922e2a17445840866b26d86e283</p>
I need to parse 0.4.0 (3612) for Android 4.3+ (Jelly Bean MR2, API 18)
, but how to parse only <p>
without strong?
Here's my parse code :
function parseFields ($) {
const h2 = $('.faq_cat').attr('id');
const info = $('meta[name="description"]').attr('content');
const version = $('ddstyle[name="p"]').attr('version')
const fields = {
h2,
info,
version
};
You can use text
function as following
$('dd').find('p').first().text();
or if need particular element then use eq
in the place of first
like
$('dd').find('p').eq(0).text();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.