kub-at / php-simple-html-dom-parser Goto Github PK
View Code? Open in Web Editor NEWPHP Simple HTML DOM Parser fork http://simplehtmldom.sourceforge.net/ (simplehtmldom - PHP 7.3+ compatible)
License: MIT License
PHP Simple HTML DOM Parser fork http://simplehtmldom.sourceforge.net/ (simplehtmldom - PHP 7.3+ compatible)
License: MIT License
Hi, i got problem when reading site that has large html code. I found out that you can set the MAX_FILE_SIZE. Now i change it directly in vendors folder and i can read the site again. Can you make a config file that i can set in app/config/
Thank you,.
I get:
Deprecated: Creation of dynamic property simple_html_dom\simple_html_dom::$optional_closing_array is deprecated in /home/rosell/github/dom-util-for-webp/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php on line 1489
From PHP 8.2, properties needs to be defined before used.
In PHP 8.2, a warning is triggered. In PHP 9.0, an error will be thrown
See: https://wiki.php.net/rfc/deprecate_dynamic_properties
I'm aware that this should be fixed in the original simple_html_dom.php, but until then, I propose that it is fixed here.
2.0 version (PHP Simple HTML DOM Parser) will be available in composer with namespaces.
Currently in 2.0RC so waiting for final release.
https://sourceforge.net/p/simplehtmldom/feature-requests/46/
After release update readme and give information about using the "original" simplehtmldom
php-simple-html-dom-parser don't work with cURL
I'm using this package to parse 2 HTML pages which I suppose are identical in structure.
$firstPageHTML = 'https://controlc.com/bfa5ec9a'
$secondPageHTML = 'https://controlc.com/e8188d3e'
$parser = HtmlDomParser::str_get_html($secondPageHTML);
It seems that when I try to parse the second page HTML, HtmlDomParser's str_get_html
method doesn't log anything. Eventually I get the following error:
Call to a member function find() on bool
$tableLength = count($parser->find('div[id="content"] table[class="tabelcalorii"] tr')) - 2;
What could be the issue here? $firstPageHTML
works fine, using the latest version of the package
LE: increasing MAX_FILE_SIZE
within simple_html_dom.php
seems to fix the issue.
Hello! I installed the library via composer and then connected it using autoload to my router. Next, I tried to use it in the file where I add articles to the site, but I got:
Fatal error: Uncaught Error: Class "simple_html_dom\simple_html_dom" not found in C:\OSPanel\domains\localhost\php\classes\Blog.php:15
Stack trace:
#0 C:\OSPanel\domains\localhost\router.php(29): classes\Blog::handlerAddArticle()
#1 C:\OSPanel\domains\localhost\php\classes\Route.php(24): {closure}()
#2 C:\OSPanel\domains\localhost\router.php(29): Route::post()
#3 {main}
thrown in C:\OSPanel\domains\localhost\php\classes\Blog.php on line 15
The file where I add the article:
namespace classes;
use simple_html_dom\simple_html_dom;
class Blog
{
public static function handlerAddArticle()
{
global $mysqli;
$title = $_POST['title'];
$content = $_POST['content'];
$author = $_SESSION['login'];
$html = new simple_html_dom();
$html->load($content);
var_dump($html);
$img = $html->getElementByTagName('img');
$meta = explode(',', $img->src)[0];
$base64 = explode(',', $img->src)[1];
$extension = explode(';', explode('/', $meta)[1])[0];
$filename = "img/blog/" . microtime() . "." . $extension;
$ifp = fopen($filename, 'wb');
fwrite($ifp, base64_decode($base64));
fclose($ifp);
$img->src = "/" . $filename;
$content = $html->save();
switch (true) {
case(empty($title) && empty($content)):
return json_encode(['result' => 'error']);
case(empty($title)):
return json_encode(['result' => 'errorTitle']);
case(empty($content)):
return json_encode(['result' => 'errorText']);
default:
$mysqli->query("INSERT INTO articles(title, content, author) VALUES ('$title', '$content', '$author')");
return json_encode(['result' => 'success']);
}
}
The 1.9 release is out: https://sourceforge.net/projects/simplehtmldom/files/simplehtmldom/1.9/
When attempting to parse all Heading tags of certain sites, there's an opening Heading tag in script data, and forceTagsClosed doesn't seem to apply.
How to avoid this H tag parsing in the script tag?
Example site: techcrunch dot com with H2 wrapped in script tags.
find('H2') for the above site example collects garbage.
Amazing script, btw! Please advise.
I have a similar problem as it is described in:
Would you take a look into it? It looks like it happened only in some specific PHP version.
Error:
PS C:\projects\kentico-cloud-sample-app-php> php artisan serve
Laravel development server started: <http://127.0.0.1:8000>
[Tue Sep 17 15:42:21 2019] PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\projects\kentico-cloud-sample-app-php\vendor\kub-at\php-simple-html-dom-parser\src\KubAT\PhpSimple\lib\simple_html_dom.php on line 146
[Tue Sep 17 15:42:21 2019] PHP Stack trace:
[Tue Sep 17 15:42:21 2019] PHP 1. simple_html_dom\simple_html_dom_node->__destruct() C:\projects\kentico-cloud-sample-app-php\vendor\kub-at\php-simple-html-dom-parser\src\KubAT\PhpSimple\lib\simple_html_dom.php:0
[Tue Sep 17 15:43:52 2019] PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\projects\kentico-cloud-sample-app-php\vendor\kub-at\php-simple-html-dom-parser\src\KubAT\PhpSimple\lib\simple_html_dom.php on line 146
[Tue Sep 17 15:43:52 2019] PHP Stack trace:
[Tue Sep 17 15:43:52 2019] PHP 1. simple_html_dom\simple_html_dom_node->__destruct() C:\projects\kentico-cloud-sample-app-php\vendor\kub-at\php-simple-html-dom-parser\src\KubAT\PhpSimple\lib\simple_html_dom.php:0
[Tue Sep 17 15:44:52 2019] PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\projects\kentico-cloud-sample-app-php\vendor\kub-at\php-simple-html-dom-parser\src\KubAT\PhpSimple\lib\simple_html_dom.php on line 146
[Tue Sep 17 15:44:52 2019] PHP Stack trace:
[Tue Sep 17 15:44:52 2019] PHP 1. simple_html_dom\simple_html_dom_node->__destruct() C:\projects\kentico-cloud-sample-app-php\vendor\kub-at\php-simple-html-dom-parser\src\KubAT\PhpSimple\lib\simple_html_dom.php:0
[Tue Sep 17 15:44:53 2019] 127.0.0.1:55071 [200]: /favicon.ico
https://github.com/Simply007/kentico-cloud-sample-app-php.git
desctructissue
composer update
php artisan serve
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.