Re: [Htmlparser-user] Can HTMLParser solve this problem ?
Brought to you by:
derrickoswald
From: Ian M. <ian...@gm...> - 2006-04-11 21:20:23
|
HTMLParser is certainly capable of rewriting bits of HTML, but bear in mind that the rest of the output may not be quite the same as the input. To get HTMLParser to make a parser from a URL, use the constructor that takes the URL as a String. If you've got the page as a String already, then do Parser.setInputHTML. Then modify the document as you see fit, then use the toHTML method for the root document obtained from doing parser.parse. API reference is here: http://htmlparser.sourceforge.net/javadoc/index.html?org/htmlparser/Parser.= html Ian On 11/04/06, pre...@wi... <pre...@wi...> wrote: > > > > Hi All, > > > > Following is the requirement of my project > > > > Requirement > > > > I need to write a java proxy so that I have the handle to all the request= s > that are made to a particular site. This is so that I can charge the end > user. I have written a java code which connects to a particular URL gets = the > HTML data and forwards the same to the client. > > > > Problem area > > > > I want to parse the HTML returned from the site requested by user and app= end > or change the value of some tags eg > > > > href=3D"http://groups.google.co.in/grphp?hl=3Den&tab=3Dwg&ie=3DUTF-8"> > > > > To be changed to something like > > > > href=3D"http://localhost:8080/pageRedirect?page=3D"http://groups.google.c= o.in/grphp?hl=3Den&tab=3Dwg&ie=3DUTF-8""> > > > > So that the request is redirect back to my proxy server and I extract the > value of the page parameter and forward the request. > > > > Can I achieve this parsing and translation using HTML parser? > > Can you please provide me with any sample code? > > > > Thanks & Regards > > Prerna Sawhney > > |