Solved

Is there a script I can run that will pull phone numbers and emails from a website?

Posted on 2011-09-15
5
225 Views
Last Modified: 2012-05-12
I am creating a list of phone numbers and emails from this site: http://www.golfnationwide.com/US-Golf-Course-List-And-Directory.aspx.  Is there a script I can run that would essentially crawl this site and return all of the email and phone numbers?
0
Comment
Question by:tprofits
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 36544364
Not really...
If you've some $$$ go on one of the following site :
https://www.odesk.com/
http://www.rent-acoder.com/
http://www.freelancer.com/
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 36544524
if you're interested in hiring someone to do the work, I'd be willing to offer my services. I'll charge less as I'm trying to build up my portfolio.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36544595
0
 

Author Comment

by:tprofits
ID: 36544836
The_Big_Daddy - Contact me at tjback@gmail.com.
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 36549135
You will need a list of all the golf clubs.  They are listed by state.  So you will first want to scrape this page:
http://www.golfnationwide.com/Default.aspx

Then for each state, you will find a list that looks like this.  You will need to collect the URLS for each of the club links.
http://www.golfnationwide.com/Golf-Courses-By-State/Virginia-Golf-Courses__VA.aspx

Once you have those URLs, they will point to pages like this:
http://www.golfnationwide.com/Golf-Courses-By-State/Virginia/Belle-Haven-Country-Club___32739.aspx

The code snippet shows how to isolate the information you want for each of the clubs.

Best of luck with your project, ~Ray
<?php // RAY_temp_tprofits.php
error_reporting(E_ALL);


// ONE OF THE PAGES TO SEARCH
$url = 'http://www.golfnationwide.com/Golf-Courses-By-State/Virginia/Belle-Haven-Country-Club___32739.aspx';
$htm = file_get_contents($url);

// THE THINGS WE DO NOT NEED
$junk = array
( '<span id="Block">'
, '<span id="CourseImage">'
)
;

// THE THINGS WE WANT TO FIND
$things = array
( 'ctl00_MainContentPlaceholder_CourseNameLabel' => 'NAME:  '
, 'ctl00_MainContentPlaceholder_EmailLabel'      => 'EMAIL: '
, 'ctl00_MainContentPlaceholder_PhoneLabel'      => 'PHONE: '
)
;

// AVOID SEARCHING THROUGH ALL THE NOISE
$arr = explode($junk[0], $htm);
$arr = explode($junk[1], $arr[1]);
$htm = $arr[0];

// SEARCH THE STRINGS
foreach ($things as $target => $thing)
{
    // CONSTRUCT A REGULAR EXPRESSION
    $regex
    = '#'        // REGEX DELIMITER
    . '\<span'   // OPEN-SPAN TAG
    . '.*?'      // ANYTHING OR NOTHING
    . $target    // THE SEARCH STRING
    . '.*?'      // ANYTHING OR NOTHING
    . '\>'       // END OF THE OPEN-SPAN TAG
    . '(.*?)'    // GROUP OF CHARACTERS
    . '\</span'  // CLOSE-SPAN TAG
    . '#'        // REGEX DELIMITER
    . 'i'        // CASE-INSENSITIVE
    ;

    // SEARCH THE HTML FRAGMENT
    preg_match($regex, $htm, $mat);
    $new[$thing] = $mat[1];
}

// SHOW THE WORK PRODUCT
echo "<pre>";
print_r($new);

Open in new window

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Split wordpress loop 35 56
PHP Soap Server returning XML but < & > as &lt; / &gt; 9 45
Ajax and PHP 9 29
MSSQL - Lock Row from reading by other programs 9 34
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question