Get HTML source code of page with php – Scrape

Get HTML source code of page with php – Scrape

In this Post We Will Explain About is Get HTML source code of page with php – Scrape With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to php – Scrape web page contents Example

In this post we will show you Best way to implement How To Scrape Data From Website Using PHP, hear for Simple way of scraping a website using PHP with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Include External Libs

<script type="text/javascript" src="http://code.jquery.com/jquery-1.12.4.js"></script>
<!-- Devloped by https://www.pakainfo.com free download examples -->
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<!-- Devloped by https://www.pakainfo.com free download examples -->
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap.min.js"></script>

index.html

<!-- Devloped by https://www.pakainfo.com free download examples -->
<table id="live_example_table" class="table table-striped table-bordered" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>End Date</th>
                <th>Computer</th>
                <th>It</th>
                <th>Javascript</th>
                <th>jQuery</th>
                <th>Laravel</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>End Date</th>
                <th>Computer</th>
                <th>It</th>
                <th>Javascript</th>
                <th>jQuery</th>
                <th>Laravel</th>
            </tr>
        </tfoot>
<!-- Devloped by https://www.pakainfo.com free download examples -->
<?php

$htmlContent = file_get_contents('https://masternodes.online/');
$DOM = new DOMDocument();
	$DOM->loadHTML($htmlContent);
	
	$Header = $DOM->getElementsByTagName('th');
	$row = $DOM->getElementsByTagName('td');
    //#Get header name of the table
	foreach($Header as $NodeHeader) 
	{
		$aDataTableHeaderHTML[] = trim($NodeHeader->textContent);
		
	}

	
	foreach($row as $NodeHeader) 
	{
		$str[] = trim($NodeHeader->textContent);
	}

$mytable = "<tbody><tr>";

for($i = 0; $i < count($str); $i++)
{

	if ((($i % 11) - 2) == 0) 
	{
		$start  = strpos($str[$i], '(');
		$end    = strpos($str[$i], ')', $start + 1);
		$length = $end - $start;
		$result = substr($str[$i], $start + 1, $length - 1);
	}
	
	if ((($i % 11) - 2) == 0) 
	{
		$mytable .= "<td><img src='https://masternodes.online/coin_image/".$result.".png' width='16' height='16' title='CoinonatX masternode' alt='CoinonatX masternode'></td><td>".$str[$i]."</td>";
	}
	else
	{
			if($str[$i] != '')
			{
				$mytable .= "<td>".$str[$i]."</td>";
			}
			
	}			
	if($i % 11 ==0 && $i != 0)
	{
		 $mytable .= "</tr><tr>";
	}		
}

$mytable .= "</tr></tbody></table>";

echo $mytable;
?>

index.js

$(document).ready(function() {
    $('#live_example_table').DataTable();
} );

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Also Read This πŸ‘‰   jQuery AJAX POST using PHP Tutorial with Example

Example

I hope you have Got What is how to get html content from html file in php And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.