My last article was written in Feb this year. I was extremely busy on my internet retail business in the last eight months, as well as putting a lot of effort to release a price comparison engine for Malaysia's ecommerce market, BijakMall.com. Bijak Mall collects product information from various internet malls in Malaysia and indexes into database. Potential buyers then able to search and compare prices through Bijak Mall's search engine. I started this project under XAMPP environment so that I can use my laptop to test the scripts. I wrote web spiders in PHP to collect products' data and store into MySQL database. Sphinx Search Server (Windows version) is used to index the database and response to user query. Sphinx is a free software/open source Fulltext search engine designed to provide full-text search functionality to client applications.
In this final part of PHP/cURL email extractor, I will show you how to store extracted data into MySQL database. You can store email addresses and contact information collected not just from one website, but also from various websites into the same database.
You might want to store email collected based on your purpose. For example, if you have a real estate website and a internet shopping website, then information collected should be stored into two different categories (tables in MySQL database).
First, you need to activate XAMPP on your PC, both Apache and MySQL. At browser URL, go to "http://localhost/phpmyadmin/". Go to top menu bar and select "Database". To create a new database for our tutorial, enter "email_collection" and press "Create" button, as shown in the picture below.
You can download the source file for PHP cURL Email Extractor from here.
Before we start writing PHP code, it is good to install XAMPP package from Apache Friends. XAMPP is a full-featured AMPP (Apache, MySQL, PHP, Perl) and a non-commercial middleware stacks available on Linux. After installation, you can use your local PC or laptop to run web bot or spider scripts, or even test out a full-featured product site, such as Joomla or Wordpress before upload to live server.
XAMPP is very stable and you can run screen scraping scripts for weeks from your PC without problems, assuming your scripts are clean, no memory leak etc. Domain name and web hosting are not needed to run your PHP/MySQL program on XAMPP. Sometimes you do not even need internet access during script writing.