|
Posted by Rik on 10/27/06 10:03
Cleverbum@hotmail.com wrote:
> I was hoping to parse a webpage and extract all link and image URLs
> from it and enter the new ones into mySQL tables, below is my code to
> do it, I've tried to optimise it as much as I can but it still takes
> too long to execute (server timeouts on a server which I can not
> control) I was wondering if there was some way to compile the code or
> if anyone can spot something which could be better written.
> Thanks in advance,
> Martin
Well, it would be simpler for us if you could describe what it is exactly
what you're trying to do, instead of letting us decypher it.
1. You can use a WHERE REGEXP to have a small result to check from the
database.
2. In the case, I really advise preg_replace() to change the img src
instead of the exploding, looping strpos, str_replace etc. This can be a
one-liner.
3. MySQL has a handy REPLACE INTO, as long as you have a correct key, it
would mean that no checking on already existing rows is required.
--
Rik Wasmus
Navigation:
[Reply to this message]
|