Skip to content

Instantly share code, notes, and snippets.

@dev-w3
Created March 11, 2021 05:15
Show Gist options
  • Save dev-w3/81c711466d64d27eee74035a032bd0a2 to your computer and use it in GitHub Desktop.
Save dev-w3/81c711466d64d27eee74035a032bd0a2 to your computer and use it in GitHub Desktop.
<?php
$curl = curl_init('https://www.domain.com/outwell/posadas-foldaway-bed-single');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$page = curl_exec($curl);
$related_products = array();
// Get Content Inside of productdetail_lblProductName Div/ Regex Match
$regex = '/<div id="productdetail_lblProductName">(.*?)<\/div>/s';
if ( preg_match($regex, $page, $list) )
echo $list[1];
else
print "Not found";
@dev-w3
Copy link
Author

dev-w3 commented Mar 11, 2021

#Data Scrapping using cURL / Regex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment