Get the phone numbers from existing website

3 replies
Hello Guys,

I want to get all the phones numbers from the deals from this site.

How it can be done.

I have this following code where i get all the website and displaying on my site but i need just the phone numbers.
<?php
$urltopost = "http://deals.vconnect.com/lagos.html";
$datatopost = array ();
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
?>
<?php echo $returndata; ?>

The code where is displayed phone number is follow:

<a rel="external" style="text-decoration: none; color: #444;" href="tel:08033511964" onclick="dataLayer.push({'eventCategory' : 'OfferDPageLeads', 'eventAction' : 'IconClick', 'eventLabel': 'PhoneNoClick', 'eventValue' : '1', 'event' : 'PhoneNoClick'});">

08033511964
</a>
#existing #numbers #phone #website
  • Profile picture of the author Brandon Tanner
    Once you have the string that contains the source code, split it into an array using the " delimiter...

    $source_code_array = explode('"', $source_code);

    Now create a new array that will hold the phone #'s...

    $phone_numbers = array();

    Then for each item in the source code array, check to see if the item contains the string "tel:". If so, remove the "tel:" part, then add the item to the phone numbers array...

    foreach ($source_code_array as $array_item) {
    if (strpos($array_item, "tel:") !== false) {
    $array_item = str_replace("tel:", "", $array_item);
    array_push($phone_numbers, $array_item);
    }
    }
    Signature

    {{ DiscussionBoard.errors[9347082].message }}
    • Profile picture of the author mbmkd88
      Originally Posted by Brandon Tanner View Post

      Once you have the string that contains the source code, split it into an array using the " delimiter...

      = explode('"', );

      Now create a new array that will hold the phone #'s...

      = array();

      Then for each item in the source code array, check to see if the item contains the string "tel:". If so, remove the "tel:" part, then add the item to the phone numbers array...

      foreach ( as ) {
      if (strpos(, "tel:") !== false) {
      = str_replace("tel:", "", );
      array_push(, );
      }
      }
      This is cool. It's work. But one more thing is how can i get the phone from every deal. I hope that there is a way to list all of them and get the phones (not one by one).

      Example:

      this is the root of the website: http://deals.vconnect.com/lagos.html

      Deal one: http://deals.vconnect.com/afrizone-m...re-lagos_of477

      Deal two: http://deals.vconnect.com/vconnect-g...re-lagos_of464

      Deal three: http://deals.vconnect.com/best-choic...lo-lagos_of467

      e tc till the last offer,

      Thanks
      {{ DiscussionBoard.errors[9347253].message }}
      • Profile picture of the author Brandon Tanner
        You would need to put a list of all the URL's into an array. Then, using a foreach loop, extract the source code from each URL in the array. For the extraction part, you can use CURL, or file_get_contents, or whatever.
        Signature

        {{ DiscussionBoard.errors[9348677].message }}

Trending Topics