473,800 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert some files from html to plaintext

I have many html files named like these:

c:\dir\femo-black.html
c:\dir\loren-white.html
c:\dir\spark-white.html
c:\dir\kim-black.html
c:\dir\paul-white.html

How can I convert only the files named "c:\dir\*-white.html" to
plaintext files named c:\dir\(origina l filename)-text.txt?

Is there a PHP module that does a good quality conversion HTML to
plaintext?

Nov 11 '07 #1
7 1855
On Nov 11, 1:05 pm, Luca Villa <lucavi...@cash ette.comwrote:
I have many html files named like these:

c:\dir\femo-black.html
c:\dir\loren-white.html
c:\dir\spark-white.html
c:\dir\kim-black.html
c:\dir\paul-white.html

How can I convert only the files named "c:\dir\*-white.html" to
plaintext files named c:\dir\(origina l filename)-text.txt?

Is there a PHP module that does a good quality conversion HTML to
plaintext?
See this:

<http://www.php.net/strip_tags>

Nov 11 '07 #2
See this:
>
<http://www.php.net/strip_tags>
Isn't there something of higher quality, like the rendering engine of
the textual browser Lynx?

Nov 11 '07 #3
On Nov 11, 8:58 pm, Luca Villa <lucavi...@cash ette.comwrote:
See this:
<http://www.php.net/strip_tags>

Isn't there something of higher quality, like the rendering engine of
the textual browser Lynx?
I guess you dont't simply want to remove all the tags. You rather want
to make sure, that the content of your <h1>-element is followed by an
empty line or that your <p>-elements are indented, etc.

This might seem a little oversized, but if all of your files have the
same structure, you might want to create an XSLT and have PHP
transform it to whatever strucure you prefer.

Check out the PHP manual here http://www.php.net/ref.xsl and maybe
this tutorial on XSLT http://www.w3schools.com/xsl/

Oli

Nov 11 '07 #4
Oli, there are ready and open source converters available like Lynx,
Links, ELinks, W3M etc...
I think that it's not the case to re-write with XSLT what's it's
already done by others with many years of work.
I hoped that PHP had an integrated solution for this, like the engine
of one of the mentioned textual browsers...

Nov 11 '07 #5
Luca Villa wrote:
Oli, there are ready and open source converters available like Lynx,
Links, ELinks, W3M etc...
I think that it's not the case to re-write with XSLT what's it's
already done by others with many years of work.
I hoped that PHP had an integrated solution for this, like the engine
of one of the mentioned textual browsers...
Usually very simple. Install Lynx on youre server and call Lynx by one
of the command executing functions of PHP:

http://php.net/exec

Other Options you dont have without alot of work...

So long, Ulf

--
_,
_(_p Ulf [Kado] Kadner
\<_)
^^
Nov 12 '07 #6
Usually very simple. Install Lynx on youre server and call Lynx by one
of the command executing functions of PHP:
That's the road I'm following, but calling an external program
thousands of times (I need to process thousand of files) is not much
efficient...

Nov 12 '07 #7
Luca Villa wrote:
>Usually very simple. Install Lynx on youre server and call Lynx by one
of the command executing functions of PHP:

That's the road I'm following, but calling an external program
thousands of times (I need to process thousand of files) is not much
efficient...
sure, not a performance wonder :-)

better you write a shellscript that reads all resources from a file
(maybee dynamic generated) and handles it by lynx in a loop. Thats faster

So long, Ulf

--
_,
_(_p Ulf [Kado] Kadner
\<_)
^^
Nov 13 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2946
by: LRW | last post by:
Because I've had recipients of our newsletter tell us they can't (or won't) receive HTML e-mail, I found out how to make an e-mail that sends both HTML and a plaintext version in a multipart message. Problem is, while the HTML version shows up fine in HTML enabled clients like Outlook, in plaintext clients it either shows nothing in the body or just an attachment link to the message source code. I've tried different encodings and bits...
7
2214
by: news | last post by:
Before I begin, I realise there's a big war regarding HTML in e-mails. Personally, I don't like it. Unfortunately, I'm being paid by my company to create an automated newsletter for our customers. I did all I could just to get them to allow me to have it sent in both plaintext and HTML so that the e-mail clients have a choice. Anyway. I've looked around the RFC's and the source of similar e-mails, and I'm certain I figured out how to do...
6
7094
by: Joerg Battermann | last post by:
Hey there, mmmm does anyone know a library or anything I can use to convert plaintext to html real quick and vice-versa? Regex surely would do the trick to a certain level, but maybe there's already a useful library out there which I might have a look at.. Thanks, -J
2
1554
by: neeraja.ram | last post by:
Hello All, I am just learning XML. I need your help in converting a text file to XML. The text file is not a delimited one for me to do the things easily. for eg. a sample file could be like... First Name : abcd Last Name : xyz
4
4480
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my server. Does anyone have any examples on how to do this ?? I dont really understand how to get from HTML string to HTML document. I can probably work out how to save this. do i create an html object ??
2
2953
by: mseiferle | last post by:
I was searching around the web for a while now und could not find any any implementation going that way, my intention is to convert html newsletters to markdown Syntax when sending them to people that only want plaintext. Any Ideas or suggestions?
5
3649
by: Just Another Victim of the Ambient Morality | last post by:
I've done a google search on this but, amazingly, I'm the first guy to ever need this! Everyone else seems to need the reverse of this. Actually, I did find some people who complained about this and rolled their own solution but I refuse to believe that Python doesn't have a built-in solution to what must be a very common problem. So, how do I convert HTML to plaintext? Something like this: <div>This&nbsp;is&nbsp;a&nbsp;string.</div>
4
1951
by: =?ISO-8859-1?Q?Andreas_M=FCller?= | last post by:
Hi! I'm looking for a technical primer regarding programming correct HTML newsletters. E.g. I remember reading about inline jpegs to avoid attachment problems and the like :-) Thanks for your hints / links and ideas. Best regards, Martin
3
3116
by: CJM | last post by:
David, Thanks for the reply. Responses inline: "David E. Ross" <nobody@nowhere.notwrote in message news:OZadnaBdOMGpYb3VnZ2dnUVZ_vOdnZ2d@softcom.net... This is a promotional mailshot so image is important. I understand what you
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.