Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

(Release) Easy Scrapping of HTML Content..

Hey!

So while working on countless scraper scripts, I have compiled my own little PHP Class to do the process as simple & handy as I want it to be.. :)

So why keep it for my-self, and not share my work? Hell yeah!

This will come in very handy for you, if you need a very quick way to do data scraping with minimal effort! If you have any questions or requests, please contact me.

/Scraper.php
https://rentry.co/daiub

Basic Example:
PHP Code

<?php 
    
function PullTableData($url) {

        if($content = $this->curl($url)) {
            $listings_html = $this->getValueByTagName($content, '<div id="mainblock">', '<div class="leftblock">');
            $listings_html_Arr = explode('<div class="lbm">', $listings_html);
            array_shift($listings_html_Arr);

            foreach($listings_html_Arr as $key => $data) {
                // populate data with info returned by $data & $key..
                $items[$key] = array(
                    'identifier' => 'paramter'
                );
            }
        }
        else {
            echo 'Unable to load the URL Provided: ' .$url;
            return false;
        }
        return $items;
    } 

Let me know if you need any further instructions on how to utilize the methods within this class.
Very cool stuff there buddy!
[Image: O444cFs.jpg]
Nice, great start!

One thing you should explore is xpath routes so you can more easily fetch data. It is faster than using explodes.
The regex, string searches, length checks, etc, may be slower than using something like Domxpath or a similar package. Your code though is impressive and I am glad it works and appears to be user friendly too.

I was making PHP crawlers back in 2015-18 and was able to power a lot of businesses with data because of it. Are you using your scripts for anything right now?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by flexing_99Apr 29, 2023 12:02 AM 3 269 Apr 29, 2023 12:02 AM
Last Post: Zgh600
[Javascript]  by flexing_99Jul 4, 2020 04:11 PM 0 130 Jul 4, 2020 04:11 PM
Last Post: flexing_99
[Javascript]  by AreWeRealApr 6, 2020 02:22 AM 5 210 Apr 6, 2020 02:22 AM
Last Post: AreWeReal