javascript - Extracting text between end and start of tags -


i'm looking extract telephone number:

i using nodejs / expressjs / request / cheerio.

this code part of web crawler.

<div class="info">    <h3> home </h3>    <p>      <strong> tel: </strong>      01345 000000      <strong> fax: </strong>      01345 000000    </p>    <p>    </p>

i'm able retrieve text "tel:".

here's progress i've made:

$('div.info p').filter(function() {    $(this).find('strong').filter(function() {      var phonenumber = $(this).text();      console.log(phonenumber);    });  });

this should work:

var temp = $('p');  temp = temp.text().trim();  temp = temp.substring(4, 22);    $('.info').html(temp);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>    <div class="info">    <h3> home </h3>    <p>      <strong> tel: </strong>      01346 000000      <strong> fax: </strong>      01345 000000    </p>    <p>  </p>


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -