Comments (6)
It sounds like it's loading a different DTD (XHTML instead of HTML5 or something) or encoding. Could you post the HTML file you're trying to translate? Perhaps you can try minimise the HTML file to the smallest file that creates these errors?
from html2text.
Thanks for the prompt response - The HTML was from this article: http://www.smh.com.au/digital-life/computers/gadgets-on-the-go/getflix-offers-the-best-of-both-worlds-20150406-1mf3aa.html
What I did encoding wise - and what I did before putting that article into HTML2TEXT - I'll shed light on momentarily for you.
from html2text.
Very sorry for delay in providing proper issue details to you.
I am running the following:
$article_URL = (example provided above) http://www.smh.com.au/digital-life/computers/gadgets-on-the-go/getflix-offers-the-best-of-both-worlds-20150406-1mf3aa.html
$webpage_html_object = new DOMDocument();
$webpage_html_object->loadHTMLFile($article_URL);
$body = $webpage_html_object->getElementsByTagName('body');
if ( $body && 0<$body->length ) {
$body = $body->item(0);
$webpage_body_html_string = $webpage_html_object->savehtml();
}
Then:
$as_plaintext = convert_html_to_text($webpage_body_html_string);
At one time I used, but have since commented out this line in preference of the above:
$webpage_body_html_string = $webpage_html_object->savehtml($body);
from html2text.
It looks like the HTML is invalid, so similar to issue #10. Maybe we can look at adding an option to ignore invalid HTML warnings...
What happens if you parse the HTML directly?
$as_plaintext = convert_html_to_text(file_get_contents("http://www.smh.com.au/digital-life/computers/gadgets-on-the-go/getflix-offers-the-best-of-both-worlds-20150406-1mf3aa.html"));
from html2text.
okay trying that returns more issues:
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 151 in /home/content/20/10935220/html/engineroom/assets/src/Html2Text.php on line 40
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 154 in /home/content/20/10935220/html/engineroom/assets/src/Html2Text.php on line 40
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 157 in /home/content/20/10935220/html/engineroom/assets/src/Html2Text.php on line 40
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 160 in /home/content/20/10935220/html/engineroom/assets/src/Html2Text.php on line 40
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: expecting ';' in Entity, line: 166 in /home/content/20/10935220/html/engineroom/assets/src/Html2Text.php on line 40
I don't have any problems with a slightly older version of your html2text script -
from html2text.
If you have invalid HTML I recommend running it through Tidy first.
from html2text.
Related Issues (20)
- PHP 8.2 Support HOT 1
- mb_convert_encoding is DEPRECATED in php 8.2 HOT 2
- MIT License HOT 3
- Support RTL
- New release HOT 3
- Using < character as input to html2text HOT 5
- Strip zero width non joiners HOT 1
- Causes failure with AWS SES when sending RAW email with attachments HOT 6
- Minimal version of PHP ? HOT 1
- random DOMDocument::loadHTML() error HOT 3
- Incorrect operation of the drop_links option
- Problem decoding certain unicode representations HOT 1
- Leaves ampersand in href
- ErrorException: Required parameter $options follows optional parameter $prevName HOT 2
- 💀 Dead project? HOT 5
- Looking for maintainer HOT 12
- Ability to change number of new lines in output HOT 1
- Links without text should be discarded
- PHP8.1, Deprecated: Optional parameter $prevName declared before required parameter $options HOT 2
- error for correct url with multiple get params
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html2text.