Building a reusable scraping class (Advanced)

Given the recipes we have completed so far, we are in a position where we can take on most scraping tasks that we may come across by developing a solution specific to any problem we may encounter. While this is a perfectly suitable approach, and is necessary for very large projects; for the types of small projects we will usually find ourselves feeling that it is overly time-consuming, and will see us often repeating ourselves.

In this recipe we will introduce some basic Object oriented programming (OOP) techniques to build a scraping class, which can be easily expanded and reused for any projects we may embark on in the future.

How to do it...

  1. Enter the following code into a new PHP file:
    <?php class ...

Get Instant PHP Web Scraping now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.