Below is the html code from which I want to fetch some data.
<div class="NS_projects__stats">
<div class="digits_4" id="stats">
<div class="row">
<div class="col col-12 mb1 stat-item">
<div class="num h1 bold" data-backers-count="107" id="backers_count">
<data class="Project1135352094" data-format="number" data-value="107" itemprop="Project[backers_count]">107</data>
</div>
<span class="bold h5">backers</span>
</div>
<div class="col col-12 mb1 stat-item">
<div class="num h1 bold nowrap" data-goal="8000.0" data-percent-raised="0.909875" data-pledged="7279.0" id="pledged">
<data class="Project1135352094" data-currency="EUR" data-format="shorter_money" data-precision="0" data-value="7279.0" data-without_code="true" itemprop="Project[pledged]">€7,279</data>
<span class="money eur project_currency_code"></span>
</div>
<span class="bold h5">
pledged of <span class="money eur no-code">€8,000</span>
<span class="mobile-hide">goal</span>
</span>
</div>
<span data-duration="30.041666666666668" data-end_time="2015-11-27T14:32:42-05:00" data-hours-remaining="566.7967307435142" id="project_duration_data"></span>
<div class="col col-12 stat-item">
<div class="num h1 bold">23</div>
<span class="text bold h5">days to go</span>
</div>
</div>
</div>
</div>
From above html code I have to fetch following data:
- 107 backers
- €7,279 pledged of €8,000 goal
- 23 days to go
I successfully scraped the first one but not able to fetch 2nd and 3rd one. Below is my PHP code (using CURL) to fetch the first one.
$html = get($url); //get function uses CURL and gets html data
$pattern = "/<div class=\"num h1 bold\"(.*?)<\/div>/s";
preg_match($pattern,$htm,$match);
$match[1] = "<div".$match[1]."</div>";
return strip_tags($match[1]);