3v4l.org

run code in 300+ PHP versions simultaneously
<?php $scraper = new DOMScraper(); //example couldent think of a site with an example table $scraper->setSite('http://www.farsnews.com/economy/agriculture')->setSource(); //get only tables with id="some_table_id" or any attribute match eg class="somthing" echo '<div>'.$scraper->getInnerHTML('div','class=ctgnewsmainpane').'</div>'; /** * Generic DOM scapper using DOMDocument and cURL */ Class DOMScraper extends DOMDocument{ public $site; private $source; private $dom; function __construct(){ libxml_use_internal_errors(true); $this->preserveWhiteSpace = false; $this->strictErrorChecking = false; } function setSite($site){ $this->site = $site; return $this; } function setSource(){ if(empty($this->site))return 'Error: Missing $this->site, use setSite() first'; $this->source = $this->get_data($this->site); return $this; } function getInnerHTML($tag, $class=null, $nodeValue = false){ if(empty($this->site))return 'Error: Missing $this->source, use setSource() first'; $this->loadHTML($this->source); $tmp = $this->getElementsByTagName($tag); $ret = null; foreach ($tmp as $v){ if($class !== null){ $attr = explode('=',$class); if($v->getAttribute($attr[0])==$attr[1]){ if($nodeValue == true){ $ret .= trim($v->nodeValue); }else{ $ret .= $this->innerHTML($v); } } }else{ if($nodeValue == true){ $ret .= trim($v->nodeValue); }else{ $ret .= $this->innerHTML($v); } } } return $ret; } function innerHTML($dom){ $ret = ""; $nodes = $dom->childNodes; foreach($nodes as $v){ $tmp = new DOMDocument(); $tmp->appendChild($tmp->importNode($v, true)); $ret .= trim($tmp->saveHTML()); } return $ret; } function get_data($url){ if(function_exists('curl_init')){ $ch = curl_init(); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); curl_close($ch); return $data; }else{ return file_get_contents($url); } } } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0190.00318.68
8.3.50.0180.00521.27
8.3.40.0090.00619.21
8.3.30.0070.00719.09
8.3.20.0110.00020.66
8.3.10.0030.00522.10
8.3.00.0050.00320.57
8.2.180.0100.00717.00
8.2.170.0150.00022.96
8.2.160.0100.01022.39
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0080.00026.16
8.2.120.0040.00417.75
8.2.110.0080.00322.38
8.2.100.0040.00819.95
8.2.90.0080.00017.75
8.2.80.0000.00818.95
8.2.70.0040.00418.05
8.2.60.0000.00817.75
8.2.50.0000.00817.88
8.2.40.0000.00818.05
8.2.30.0040.00422.69
8.2.20.0030.00517.85
8.2.10.0000.00718.23
8.2.00.0030.00518.43
8.1.280.0110.00425.92
8.1.270.0130.01024.21
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.01019.35
8.1.230.0090.00319.26
8.1.220.0030.00517.77
8.1.210.0090.00018.77
8.1.200.0060.00317.72
8.1.190.0000.00817.35
8.1.180.0050.00318.10
8.1.170.0040.00417.62
8.1.160.0080.00022.19
8.1.150.0050.00218.97
8.1.140.0030.00617.68
8.1.130.0000.00717.89
8.1.120.0000.00717.71
8.1.110.0040.00417.59
8.1.100.0040.00417.71
8.1.90.0040.00417.46
8.1.80.0000.00717.57
8.1.70.0030.00317.57
8.1.60.0050.00317.88
8.1.50.0030.00617.70
8.1.40.0030.00517.59
8.1.30.0040.00417.77
8.1.20.0040.00417.78
8.1.10.0000.00817.66
8.1.00.0050.00317.70
8.0.300.0000.00818.77
8.0.290.0000.00816.84
8.0.280.0040.00418.56
8.0.270.0000.00717.50
8.0.260.0000.00717.54
8.0.250.0040.00417.08
8.0.240.0030.00317.19
8.0.230.0000.00717.18
8.0.220.0040.00417.24
8.0.210.0040.00417.17
8.0.200.0000.00717.14
8.0.190.0000.00817.23
8.0.180.0030.00717.25
8.0.170.0030.00617.12
8.0.160.0000.00717.23
8.0.150.0080.00017.02
8.0.140.0050.00217.15
8.0.130.0000.00713.78
8.0.120.0000.00917.17
8.0.110.0080.00017.11
8.0.100.0050.00317.10
8.0.90.0040.00417.15
8.0.80.0130.00317.22
8.0.70.0080.00017.24
8.0.60.0040.00417.14
8.0.50.0000.00817.21
8.0.30.0040.01417.34
8.0.20.0100.01117.42
8.0.10.0060.00317.12
8.0.00.0090.01116.98
7.4.330.0050.00015.36
7.4.320.0030.00316.58
7.4.300.0030.00316.68
7.4.290.0070.00016.66
7.4.280.0030.00616.78
7.4.270.0000.00816.67
7.4.260.0030.00316.65
7.4.250.0050.00316.73
7.4.240.0040.00316.87
7.4.230.0030.00516.83
7.4.220.0070.01416.79
7.4.210.0100.01016.88
7.4.200.0000.00716.86
7.4.160.0170.00316.79
7.4.150.0150.00317.40
7.4.140.0100.01217.86
7.4.130.0060.01416.88
7.4.120.0130.00616.81
7.4.110.0120.00616.67
7.4.100.0140.00616.67
7.4.90.0080.01116.85
7.4.80.0170.00719.39
7.4.70.0140.00616.82
7.4.60.0070.01316.67
7.4.50.0030.00316.96
7.4.40.0190.01016.75
7.4.30.0040.01816.80
7.4.10.0000.01215.33
7.4.00.0080.00615.20
7.3.330.0030.00313.61
7.3.320.0050.00013.47
7.3.310.0020.00516.68
7.3.300.0040.00416.63
7.3.290.0090.00916.71
7.3.280.0110.01016.72
7.3.270.0160.00917.40
7.3.260.0170.00816.89
7.3.250.0100.01016.68
7.3.240.0060.01616.52
7.3.230.0030.01416.77
7.3.210.0090.01016.64
7.3.200.0110.00816.83
7.3.190.0130.01016.85
7.3.180.0100.00716.89
7.3.170.0070.01316.90
7.3.160.0120.00916.76
7.3.130.0040.00815.50
7.3.120.0080.00415.05
7.3.110.0100.00315.32
7.3.100.0070.00715.25
7.3.90.0060.00915.20
7.3.80.0070.01515.09
7.3.70.0070.00715.22
7.3.60.0090.00614.88
7.3.50.0060.01314.95
7.3.40.0090.00915.22
7.3.30.0060.00614.92
7.3.20.0070.00716.99
7.3.10.0090.00916.93
7.3.00.0040.01116.64
7.2.330.0090.01117.07
7.2.320.0080.01417.15
7.2.310.0200.00317.05
7.2.300.0070.01017.10
7.2.290.0060.01216.89
7.2.260.0100.00315.66
7.2.250.0060.00615.60
7.2.240.0030.01015.43
7.2.230.0100.01015.20
7.2.220.0060.01215.59
7.2.210.0030.01315.61
7.2.200.0030.01015.17
7.2.190.0100.01015.25
7.2.180.0080.01215.52
7.2.170.0040.01115.18
7.2.160.0040.01215.46
7.2.150.0060.01217.06
7.2.140.0080.00817.21
7.2.130.0100.00717.33
7.2.120.0070.00716.95
7.2.110.0030.01517.26
7.2.100.0030.01117.31
7.2.90.0130.00717.28
7.2.80.0030.01717.30
7.2.70.0060.01317.05
7.2.60.0120.01017.11
7.2.50.0030.01016.87
7.2.40.0100.00317.32
7.2.30.0170.00017.30
7.2.20.0040.01417.34
7.2.10.0030.01017.15
7.2.00.0050.01118.30
7.1.330.0080.00515.89
7.1.320.0070.01016.12
7.1.310.0090.00316.18
7.1.300.0040.00716.11
7.1.290.0100.01015.77
7.1.280.0100.00715.83
7.1.270.0090.00616.24
7.1.260.0080.00816.02
7.1.250.0100.00716.17
7.1.240.0030.00715.72
7.1.230.0080.00816.16
7.1.220.0030.01016.22
7.1.210.0030.01116.02
7.1.200.0070.00716.05
7.1.190.0000.01315.79
7.1.180.0040.01116.13
7.1.170.0100.00316.25
7.1.160.0000.01216.12
7.1.150.0040.00816.14
7.1.140.0000.01516.07
7.1.130.0040.01216.13
7.1.120.0150.00316.03
7.1.110.0000.01716.22
7.1.100.0070.00817.43
7.1.90.0110.00616.08
7.1.80.0100.00715.88
7.1.70.0050.01216.68
7.1.60.0080.01217.47
7.1.50.0070.01316.80
7.1.40.0070.00716.21
7.1.30.0120.00315.90
7.1.20.0040.01415.79
7.1.10.0030.01415.74
7.1.00.0020.04719.45
7.0.330.0090.00315.58
7.0.320.0120.00315.60
7.0.310.0060.01215.76
7.0.300.0000.00915.49
7.0.290.0060.00915.55
7.0.280.0090.00615.61
7.0.270.0030.01415.48
7.0.260.0030.01215.44
7.0.250.0090.00615.38
7.0.240.0130.00315.96
7.0.230.0120.00615.49
7.0.220.0000.01415.61
7.0.210.0080.00315.86
7.0.200.0060.00816.46
7.0.190.0070.00315.76
7.0.180.0030.01515.76
7.0.170.0090.00915.54
7.0.160.0140.00315.72
7.0.150.0090.00315.66
7.0.140.0090.00315.63
7.0.130.0030.01015.56
7.0.120.0050.00815.70
7.0.110.0050.00515.52
7.0.100.0070.00715.71
7.0.90.0070.00715.79
7.0.80.0050.00515.87
7.0.70.0100.00315.86
7.0.60.0120.04117.86
7.0.50.0050.04516.89
7.0.40.0070.02817.26
7.0.30.0110.04317.21
7.0.20.0190.04017.12
7.0.10.0020.03417.00
7.0.00.0030.04716.96
5.6.400.0120.00014.59
5.6.390.0090.00914.66
5.6.380.0100.00314.32
5.6.370.0030.01614.40
5.6.360.0000.01614.55
5.6.350.0040.00814.82
5.6.340.0060.00914.96
5.6.330.0090.00614.83
5.6.320.0030.01214.54
5.6.310.0030.01014.59
5.6.300.0000.01514.89
5.6.290.0000.01214.77
5.6.280.0110.01718.02
5.6.270.0110.00414.88
5.6.260.0080.00614.57
5.6.250.0070.00714.68
5.6.240.0110.00414.83
5.6.230.0030.00914.59
5.6.220.0060.01014.65
5.6.210.0020.04917.72
5.6.200.0080.02916.47
5.6.190.0070.03917.83
5.6.180.0260.02317.80
5.6.170.0180.04017.81
5.6.160.0060.04617.72
5.6.150.0080.04616.52
5.6.140.0030.04416.53
5.6.130.0070.02316.55
5.6.120.0050.02518.00
5.6.110.0040.02518.04
5.6.100.0080.04318.08
5.6.90.0070.04317.89
5.6.80.0040.03817.69
5.6.70.0070.00714.56
5.6.60.0100.00014.60
5.6.50.0000.01414.53
5.6.40.0060.00314.27
5.6.30.0030.01314.72
5.6.20.0060.01214.39
5.6.10.0110.00414.48
5.6.00.0060.01014.68
5.5.380.0090.00614.43
5.5.370.0050.00614.19
5.5.360.0080.00914.73
5.5.350.0170.04017.70
5.5.340.0050.04616.48
5.5.330.0050.02617.71
5.5.320.0100.03117.66
5.5.310.0100.03017.51
5.5.300.0020.04416.63
5.5.290.0090.04316.39
5.5.280.0050.03017.82
5.5.270.0100.02517.81
5.5.260.0110.02517.93
5.5.250.0050.04117.65
5.5.240.0100.03517.53
5.5.230.0050.00514.81
5.5.220.0070.00714.56
5.5.210.0100.00414.36
5.5.200.0060.01014.34
5.5.190.0060.00314.79
5.5.180.0070.01014.62
5.5.170.0040.01114.59
5.5.160.0100.00714.18
5.5.150.0070.01014.52
5.5.140.0090.00614.59
5.5.130.0040.01114.43
5.5.120.0110.00314.77
5.5.110.0100.00714.39
5.5.100.0070.00714.70
5.5.90.0070.01014.34
5.5.80.0110.00614.43
5.5.70.0080.00314.42
5.5.60.0040.01114.52
5.5.50.0110.00414.37
5.5.40.0030.00814.24
5.5.30.0030.01314.69
5.5.20.0070.01014.44
5.5.10.0070.01014.53
5.5.00.0060.00614.56
5.4.450.0330.03315.57
5.4.440.0350.02915.72
5.4.430.0390.02515.57
5.4.420.0470.03715.49
5.4.410.0450.02515.73
5.4.400.0390.03115.44
5.4.390.0420.03715.57
5.4.380.0410.03015.58
5.4.370.0350.03015.40
5.4.360.0350.03115.46
5.4.350.0410.02315.56
5.4.340.0350.03215.54
5.4.330.0000.00911.41
5.4.320.0500.03815.50
5.4.310.0420.03115.58
5.4.300.0530.03615.61
5.4.290.0470.02715.57
5.4.280.0370.02715.50
5.4.270.0270.03515.61
5.4.260.0400.02715.40
5.4.250.0350.02815.57
5.4.240.0330.03115.65
5.4.230.0490.03015.63
5.4.220.0360.02715.56
5.4.210.0410.03115.43
5.4.200.0450.02915.47
5.4.190.0450.03015.54
5.4.180.0380.03515.54
5.4.170.0520.03215.60
5.4.160.0410.03115.32
5.4.150.0480.02715.51
5.4.140.0480.02714.15
5.4.130.0450.03014.17
5.4.120.0420.03014.03
5.4.110.0450.03314.41
5.4.100.0400.03414.15
5.4.90.0360.03114.03
5.4.80.0520.03214.29
5.4.70.0100.02614.28
5.4.60.0200.03314.12
5.4.50.0190.03414.20
5.4.40.0120.03314.11
5.4.30.0110.01714.18
5.4.20.0090.02214.04
5.4.10.0180.03814.23
5.4.00.0060.00311.05

preferences:
52.5 ms | 401 KiB | 5 Q