473,503 Members | 3,740 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\(original filename)-text.txt?

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

Nov 11 '07 #1
7 1836
On Nov 11, 1:05 pm, Luca Villa <lucavi...@cashette.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\(original 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...@cashette.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
2920
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...
7
2200
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....
6
7057
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...
2
1544
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...
4
4440
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...
2
2927
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...
5
3632
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...
4
1937
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...
3
3076
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...
0
7064
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...
0
7261
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,...
0
7315
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...
0
5559
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,...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
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 ...
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.