Web Hosting Talk







View Full Version : Script Hack Question


croakingtoad
11-17-2003, 03:49 AM
I'm trying to hack this script (Mini-Fetch) a bit to get it to do what I want, but am not sure how to accomplish this. This script (http://www.mikenew.net/) is used to fetch remote HTML documents and insert them into your own site, and allows you to also modify the original code some...

Below is an example of the script variables used to remove certain code or content from your fetch:


$value = eregi_replace( "<IMG alt=[^>]*>", "", $value ); // Remove all image alt="whatever" tags
$value = eregi_replace( "<class[^>]*>", "", $value ); // Remove all variations of <class> tags.
$value = eregi_replace( "<table[^>]*>", "", $value ); // Remove ALL variations of <table> tags.
$value = eregi_replace( "<tr[^>]*>", "", $value ); // Replace <tr> tags with blank space.
$value = eregi_replace( "<td[^>]*>", "", $value ); // Remove all variations of <td> tags.
$value = eregi_replace( "<p class=\"lead\"[^>]*>", "", $value ); // Remove all variations of <td> tags.


Using the above format, what should I add to remove a certain tag and all content in between using a wildcard.

For example, if the tag is:

<p class="headline">blah blah blah 123 blah</p>

How can I get it to remove all instances of <p class="headline"> and any wildcard content until the next </p> is encountered?

digitok
11-17-2003, 04:33 AM
$value = preg_replace('/<p class="headline">.*?<\/p>/i','',$value);

croakingtoad
11-17-2003, 06:29 AM
hmmm... I've posted that in there but it doesn't seem to be working. I did make one minor change to the class type, but it still isn't working?

Here's what I have:

$value = eregi_replace( "<td[^>]*>", "", $value ); // Remove all variations of <td> tags.
$value = eregi_replace( "<p class=\"lead\"[^>]*>", "", $value );
$value = preg_replace('/<p class="lead">.*?<\/p>/i','',$value);


It doesn't change the output. You can see my other attempt right above :)

digitok
11-17-2003, 08:28 AM
Is <p class="something">text</p> all on one line?

croakingtoad
11-18-2003, 12:38 AM
No, it spans multiple lines.

hiryuu
11-18-2003, 12:52 AM
It looks like you're missing the \ before the /p. The backslash prevents it from being mistaken for the end of the expression.

digitok
11-18-2003, 01:21 AM
Hmm... I put that in the code, seems like VB is taking it out... Anyway I don't think that would work on multi lines anyway maybe change /i to /mi and see what happens also put the \ in <\/p>

croakingtoad
11-18-2003, 02:10 AM
I put that slash back in and it's working now, thanks!

You-all rock, you're always there to answer my questions, I appreciate it! :beer:

croakingtoad
11-18-2003, 02:17 AM
[deleted]