tags:

views:

45

answers:

1

Hello,

after a website mirrored using HTTrack, there is lots of ads. I just want to replace that ads by ID or class, or by text, using script (Perl, Python, Ruby, etc), or any other way

Does anyone know what script can do this job?

Thanks in advance.

--new added below--

I will use as example in presentation, and replace specific ID or class with my own content (replace all in div class="message")

<div class="message">Examples here</div>

Some website even don't use ID and class (it use table instead). So it will be better if I can replace by text (replace from start <table to end </table>)

<table width="890" border="0" cellpadding="0" cellspacing="0"
style="margin-top:1px;background-color:#606060;border-bottom:1px solid black">

<tr style="heigh...
A: 

I need this too.. javascript is not really flexible... especially if you need to exclude some part of your old static HTML website when exporting to modern web framework.

some people told me to use perl linux command... but after some searching, i found nothing about this kind of replacing.

karpal singh
All right, I get what you're trying to do. Yes, perl is extremely versatile and can easily do this (though probably awk, sed, Ruby, Python et al. could also; let's not have a language discussion). Could you *please* show us some code you need to remove? The script's approach depends entirely on the document's structure and how similar the parts to remove are. The simplest approach would be a textual search, the most complex one is parsing the HTML, deleting elements and attributes and writing back out. But we can't help until you give us some examples.
MvanGeest