From: Fabian K. <fk...@fa...> - 2011-09-03 10:49:52
|
Gilles <cod...@fr...> wrote: > I don't know if Privoxy can do this, so figured I should ask. > > I need to extract the number in the Title section (123456) and add a > link below the existing link: > ========= > <title>Page #123456</title> > ... > <a href='#' class='myclass'>Existing link</a><p> > <a href='/whatever.php?id=123456' class='myclass'>My new link</a> > ========= > > Is there a way in Privoxy to somehow extract some text from a page, > put it into global memory, and then read its value in another regex? You should be able to archive your goal with a single pcrs command: s@<title>Page \#(\d+)</title>.*<a href='\#' class='myclass'>Existing link</a><p>@\ $0\r\n<a href='/whatever.php?id=$1' class='myclass'>My new link</a>@Ugs | The result of your filter is: | | --- /home/fk/privoxy/pft/original-8849971-file-recieved.html Sat Sep 3 12:29:26 2011 | +++ /home/fk/privoxy/pft/filtered-8849971-file-recieved.html Sat Sep 3 12:29:26 2011 | @@ -1,4 +1,5 @@ | <title>Page #123456</title> | .... | <a href='#' class='myclass'>Existing link</a><p> | +<a href='/whatever.php?id=123456' class='myclass'>My new link</a> | ... Fabian |