htmlparser-user Mailing List for HTML Parser (Page 35)
Brought to you by:
derrickoswald
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(7) |
Feb
|
Mar
(9) |
Apr
(50) |
May
(20) |
Jun
(47) |
Jul
(37) |
Aug
(32) |
Sep
(30) |
Oct
(11) |
Nov
(37) |
Dec
(47) |
2003 |
Jan
(31) |
Feb
(70) |
Mar
(67) |
Apr
(34) |
May
(66) |
Jun
(25) |
Jul
(48) |
Aug
(43) |
Sep
(58) |
Oct
(25) |
Nov
(10) |
Dec
(25) |
2004 |
Jan
(38) |
Feb
(17) |
Mar
(24) |
Apr
(25) |
May
(11) |
Jun
(6) |
Jul
(24) |
Aug
(42) |
Sep
(13) |
Oct
(17) |
Nov
(13) |
Dec
(44) |
2005 |
Jan
(10) |
Feb
(16) |
Mar
(16) |
Apr
(23) |
May
(6) |
Jun
(19) |
Jul
(39) |
Aug
(15) |
Sep
(40) |
Oct
(49) |
Nov
(29) |
Dec
(41) |
2006 |
Jan
(28) |
Feb
(24) |
Mar
(52) |
Apr
(41) |
May
(31) |
Jun
(34) |
Jul
(22) |
Aug
(12) |
Sep
(11) |
Oct
(11) |
Nov
(11) |
Dec
(4) |
2007 |
Jan
(39) |
Feb
(13) |
Mar
(16) |
Apr
(24) |
May
(13) |
Jun
(12) |
Jul
(21) |
Aug
(61) |
Sep
(31) |
Oct
(13) |
Nov
(32) |
Dec
(15) |
2008 |
Jan
(7) |
Feb
(8) |
Mar
(14) |
Apr
(12) |
May
(23) |
Jun
(20) |
Jul
(9) |
Aug
(6) |
Sep
(2) |
Oct
(7) |
Nov
(3) |
Dec
(2) |
2009 |
Jan
(5) |
Feb
(8) |
Mar
(10) |
Apr
(22) |
May
(85) |
Jun
(82) |
Jul
(45) |
Aug
(28) |
Sep
(26) |
Oct
(50) |
Nov
(8) |
Dec
(16) |
2010 |
Jan
(3) |
Feb
(11) |
Mar
(39) |
Apr
(56) |
May
(80) |
Jun
(64) |
Jul
(49) |
Aug
(48) |
Sep
(16) |
Oct
(3) |
Nov
(5) |
Dec
(5) |
2011 |
Jan
(13) |
Feb
|
Mar
(1) |
Apr
(7) |
May
(7) |
Jun
(7) |
Jul
(7) |
Aug
(8) |
Sep
|
Oct
(6) |
Nov
(2) |
Dec
|
2012 |
Jan
(5) |
Feb
|
Mar
(3) |
Apr
(3) |
May
(4) |
Jun
(8) |
Jul
(1) |
Aug
(5) |
Sep
(10) |
Oct
(3) |
Nov
(2) |
Dec
(4) |
2013 |
Jan
(4) |
Feb
(2) |
Mar
(7) |
Apr
(7) |
May
(6) |
Jun
(7) |
Jul
(3) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
|
May
(3) |
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(4) |
2015 |
Jan
(4) |
Feb
(2) |
Mar
(8) |
Apr
(7) |
May
(6) |
Jun
(7) |
Jul
(3) |
Aug
(1) |
Sep
(1) |
Oct
(4) |
Nov
(3) |
Dec
(4) |
2016 |
Jan
(4) |
Feb
(6) |
Mar
(9) |
Apr
(9) |
May
(6) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2017 |
Jan
|
Feb
(1) |
Mar
(3) |
Apr
(1) |
May
|
Jun
(1) |
Jul
(2) |
Aug
(3) |
Sep
(6) |
Oct
(3) |
Nov
(2) |
Dec
(5) |
2018 |
Jan
(3) |
Feb
(13) |
Mar
(28) |
Apr
(5) |
May
(4) |
Jun
(2) |
Jul
(2) |
Aug
(8) |
Sep
(2) |
Oct
(1) |
Nov
(5) |
Dec
(1) |
2019 |
Jan
(8) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(4) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(1) |
2021 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
(1) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Eugeny N D. <bo...@re...> - 2006-07-28 21:24:31
|
Hello! I'm trying to parse this page and extract all links there: http://www.vu.lt/lt/naujienos/337/ for some reason the link to PDF file looks like: http://www.vu.lt/site_files/InfS/Naujienos/istorik??%20dienos.pdf which is wrong. It seems like some wrong charset was used? Here is part of my code which does the parsing: public LinkedList parseDocument(InputStream document, String encoding) { try { Lexer lexer = new Lexer(new Page(document, encoding)); String href; try { lexer.reset(); if (banner != null) validateBanner(lexer); lexer.reset(); Parser parser = new Parser(lexer); NodeList list = null; try { list = parser .extractAllNodesThatMatch(new InterestedTagsFilter()); } catch (EncodingChangeException e) { log.warn(e); lexer.reset(); lexer.getPage().setEncoding(parser.getEncoding()); list = parser .extractAllNodesThatMatch(new InterestedTagsFilter()); } for (SimpleNodeIterator it = list.elements(); it.hasMoreNodes();) { TagNode node = (TagNode) it.nextNode(); href = null; if (LinkTag.class.equals(node.getClass()) && validateLink((LinkTag) node)) { href = ((LinkTag) node).getLink(); } else if (ImageTag.class.equals(node.getClass()) || FrameTag.class.equals(node.getClass())) { href = node.getAttribute("src"); } else if (TitleTag.class.equals(node.getClass())) { title = ((TitleTag) node).getTitle(); } else if (BaseHrefTag.class.equals(node.getClass())) { try { baseTag = getBaseURL(new URI(((BaseHrefTag) node) .getBaseUrl(), false)); } catch (URIException e2) { } } else if (MetaTag.class.equals(node.getClass()) && "refresh".equalsIgnoreCase(((MetaTag) node) .getHttpEquiv())) { String URL = ((MetaTag) node).getMetaContent(); if (URL != null && URL.length() > 0) { String arr[] = URL.split("URL="); if (arr != null && arr.length == 2) href = arr[1]; } } if (href != null && href.length() > 0) { if (log.isDebugEnabled()) -------> log.debug(href); <----------- results.add(getURL(StringEscapeUtils .unescapeHtml(getEscapedURL(href.trim())))); } } this.encoding = parser.getEncoding(); if (log.isDebugEnabled()) log.debug(this.encoding); } catch (ParserException e1) { log.error(e1, e1); } } catch (UnsupportedEncodingException e) { log.error(e, e); } return results; } And on marked line application logs /site_files/InfS/Naujienos/istorik??%20dienos.pdf what could be wrong there? -- Eugene N Dzhurinsky |
From: Xue-Feng Y. <jus...@ya...> - 2006-07-28 21:14:58
|
I am trying to modify for the TextNodes in a lexer by TextNode.setText(String). Then I tried to print the lexer by Page toPage=lexer.getPage(); String toString=toPage.getText(); System.out.println(toString); The page was unchanged. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: kavorka <the...@gm...> - 2006-07-28 20:53:56
|
Hi Oswald, I have another question. In HTMLPARSER, is it possible to extract only the text in the webpage. In the stringextractor program, it extract also link text in the page, i want to extract "pure" text. can i do it? thanks Murat On 7/25/06, kavorka <the...@gm...> wrote: > > Hi Oswald, > > Thanks a lot for your help. > > Murat > > > On 7/24/06, Derrick Oswald <Der...@ro...> wrote: > > > > Kavorka, > > > > This should give you the meta tag, from which you can get the > > information you want: > > > > NodeList nodes = parser.parse (null); > > NodeList metas = nodes.extractAllNodesThatMatch (new TagNameFilter > > ("META")); > > MetaTag meta = (MetaTag)metas.elementAt (0); > > System.out.println (meta); > > > > Derrick > > > > kavorka wrote: > > > > > Hi all, > > > I'm new to HTML-parser. I used sample programs to understand how can i > > > find the meta data of the page but i could't use it. Do you have any > > > code samples that finds meta data of the page using HTMLparser. > > > Thank you > > > best regards > > > > > > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your > > opinions on IT & business topics through brief surveys -- and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > > _______________________________________________ > > Htmlparser-user mailing list > > Htm...@li... > > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > > > |
From: Xue-Feng Y. <jus...@ya...> - 2006-07-28 19:43:07
|
I am trying to modify for the TextNodes in a lexer by TextNode.setText(String). Then I tried to print the lexer by Page toPage=lexer.getPage(); String toString=toPage.getText(); System.out.println(toString); The page was unchanged. Does any one have idea how to modify a lexer or simply a html page? Thanks, Xue-Feng __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: kavorka <the...@gm...> - 2006-07-25 08:49:52
|
Hi Oswald, Thanks a lot for your help. Murat On 7/24/06, Derrick Oswald <Der...@ro...> wrote: > > Kavorka, > > This should give you the meta tag, from which you can get the > information you want: > > NodeList nodes = parser.parse (null); > NodeList metas = nodes.extractAllNodesThatMatch (new TagNameFilter > ("META")); > MetaTag meta = (MetaTag)metas.elementAt (0); > System.out.println (meta); > > Derrick > > kavorka wrote: > > > Hi all, > > I'm new to HTML-parser. I used sample programs to understand how can i > > find the meta data of the page but i could't use it. Do you have any > > code samples that finds meta data of the page using HTMLparser. > > Thank you > > best regards > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |
From: Derrick O. <Der...@Ro...> - 2006-07-24 03:25:32
|
Kavorka, This should give you the meta tag, from which you can get the information you want: NodeList nodes = parser.parse (null); NodeList metas = nodes.extractAllNodesThatMatch (new TagNameFilter ("META")); MetaTag meta = (MetaTag)metas.elementAt (0); System.out.println (meta); Derrick kavorka wrote: > Hi all, > I'm new to HTML-parser. I used sample programs to understand how can i > find the meta data of the page but i could't use it. Do you have any > code samples that finds meta data of the page using HTMLparser. > Thank you > best regards > |
From: Derrick O. <Der...@Ro...> - 2006-07-24 03:20:33
|
Eigeny, In general, you probably want to look at the filter package. Try running the filterbuilder application (startup script is in the bin directory) and read the help and tutorial. Using this application you can create a Java program that selects only the 'sometext' you want. Derrick Eugeny N Dzhurinsky wrote: >Hello! >I need to search for HTML code in a page, for instance the code to search >looks like this: > ><div class="someclass"><a href="somelocation" ><img src="image/here" >border="0"></a></div><span style="style2">sometext</span> > >This code could be placed as single line or formatted somehow, containing one >or more linebreaks. > >I need also to track situation while this code is commented out, or placed >outside <body> section. > >For now I created a Lexer instance for document and for this code, comparing >them token by token, but may be there is some better way? > > > |
From: Ian M. <ian...@gm...> - 2006-07-19 15:23:22
|
HTMLParser is usually capable of parsing just an HTML fragment. Parser.setInputHTML("html") and then Parser.parse(null). Ian On 7/14/06, Dennis Gesker <ge...@al...> wrote: > Since it was just a string I added html and body tags and it seems I'm > on my way. > > str = "<head><body> + str + "</head><;body>"; > > --Dennis > > Dennis Gesker wrote: > > I would like to parse a portion of html that I have in a buffer > > (String), that is to say not a complete page. The string contains an > > html table only. > > > > Could someone point to or provide some sample code for how to parse just > > a fragment of html? > > > > Dennis > > > > > > > > -- > Dennis R. Gesker > email: de...@al... > Key Id: 0xEFA10A51 > > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |
From: kavorka <the...@gm...> - 2006-07-19 11:44:23
|
Hi all, I'm new to HTML-parser. I used sample programs to understand how can i find the meta data of the page but i could't use it. Do you have any code samples that finds meta data of the page using HTMLparser. Thank you best regards |
From: Eugeny N D. <bo...@re...> - 2006-07-17 07:30:43
|
Hello! I need to search for HTML code in a page, for instance the code to search looks like this: <div class="someclass"><a href="somelocation" ><img src="image/here" border="0"></a></div><span style="style2">sometext</span> This code could be placed as single line or formatted somehow, containing one or more linebreaks. I need also to track situation while this code is commented out, or placed outside <body> section. For now I created a Lexer instance for document and for this code, comparing them token by token, but may be there is some better way? -- Eugene N Dzhurinsky |
From: Dennis G. <ge...@al...> - 2006-07-14 20:15:09
|
Since it was just a string I added html and body tags and it seems I'm on my way. str = "<head><body> + str + "</head><;body>"; --Dennis Dennis Gesker wrote: > I would like to parse a portion of html that I have in a buffer > (String), that is to say not a complete page. The string contains an > html table only. > > Could someone point to or provide some sample code for how to parse just > a fragment of html? > > Dennis > > > -- Dennis R. Gesker email: de...@al... Key Id: 0xEFA10A51 |
From: Dennis G. <ge...@al...> - 2006-07-14 20:07:47
|
I would like to parse a portion of html that I have in a buffer (String), that is to say not a complete page. The string contains an html table only. Could someone point to or provide some sample code for how to parse just a fragment of html? Dennis -- Dennis R. Gesker email: de...@al... Key Id: 0xEFA10A51 |
From: Derrick O. <Der...@Ro...> - 2006-07-01 23:34:18
|
This should give you the "Content": NodeList nodes = parser.parse (null); NodeList metas = nodes.extractAllNodesThatMatch (new TagNameFilter ("META")); System.out.println (metas.elementAt (0).getMetaContent ()); vasantha reddy wrote: > Hi, > > I am using HTML parser in my project.The HTML > parser doesn't give the contents of meta tag as its output.I need the > content of the meta tag.Is there any method that I can use to get the > content of a particular tag by giving the tag name as input? > > Thank you, > Regards, > Vasantha > > |
From: vasantha r. <hi_...@ya...> - 2006-06-29 09:32:50
|
Hi, I am using HTML parser in my project.The HTML parser doesn't give the contents of meta tag as its output.I need the content of the meta tag.Is there any method that I can use to get the content of a particular tag by giving the tag name as input? Thank you, Regards, Vasantha --------------------------------- Yahoo! India Answers: Share what you know. Learn something new Click here Catch all the FIFA World Cup 2006 action on Yahoo! India Click here |
From: Derrick O. <Der...@Ro...> - 2006-06-28 16:42:34
|
Using the NotFilter directly like that probably won't help you. As written it would return a nodelist of top level nodes (no Remarks of course), but these would include Remarks as children. What you probably want to do is override RemarkNode to return nothing from toHtml() and set this as the default node for Remarks on the PrototypicalNodeFactory via setRemarkPrototype(). Then when you issue the toHtml() on the NodeList returned from a straight parse, the contents will have the Remarks removed. Mark Stark wrote: >hello, > >can anyone explain how to usw a NodeFilter? > >NodeList l = p.parse(new NotFilter()); > >i would like to parse all nodes/tags but RemarkTags/RemarkNodes > >thanks a lot > > > > > |
From: Mark S. <htm...@ey...> - 2006-06-28 09:42:19
|
hello, can anyone explain how to usw a NodeFilter? NodeList l = p.parse(new NotFilter()); i would like to parse all nodes/tags but RemarkTags/RemarkNodes thanks a lot |
From: Mark S. <htm...@ey...> - 2006-06-27 13:45:57
|
Thanks, it works Derrick Oswald schrieb: > I think you need something like this... > > Parser parser = new Parser (); > parser.setInputHtml (html); > NodeList list = parser.parse (null); > list.visitAllNodesWith (new SegmentReplacingVisitor ()); > System.out.println (list.toHtml ()); > > ...assuming the SegmentReplacingVisitor does the right stuff to the > right nodes. > > Mark Stark wrote: > >> I dont understand. I've got a html file, manipulate some tags with my >> visitor, perhaps change an attribute value. and then? serialize the >> toHtml() output into a file and thats it? >> >> Ian Macfarlane schrieb: >> >> >>> If you do Parser.parse() you get a NodeList, and then if you call the >>> toHtml() method it will return a String of the reparsed code. >>> >>> Ian >>> >>> On 6/26/06, Mark Stark <htm...@ey...> wrote: >>> >>> >>>> hi, >>>> >>>> is it possible to change certain stirngs in a html file, without >>>> "rebuilding" it? I would like to change some string in a html file, like >>>> a dictionary lookup, but i dont want to rebuild the html file like its >>>> done in URLModifyingVisitor. >>>> >>>> Can anybody give me a hint? I've still got >>>> >>>> Parser p = new Parser(); >>>> p.setInputHTML(html); >>>> SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >>>> p.visitAllNodesWith(s); >>>> >>>> and do some text.setText() within the SegmentReplacingVisitor each time >>>> i visit a StringNode. How to save it into a translated.htm file without >>>> rebuilding it? >>>> >>>> thanks a lot >>>> >>>> >>>> Using Tomcat but need to do more? Need to support web services, security? >>>> Get stuff done quickly with pre-integrated technology to make your job easier >>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>> _______________________________________________ >>>> Htmlparser-user mailing list >>>> Htm...@li... >>>> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >>>> >>>> >>>> >>> Using Tomcat but need to do more? Need to support web services, security? >>> Get stuff done quickly with pre-integrated technology to make your job easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>> _______________________________________________ >>> Htmlparser-user mailing list >>> Htm...@li... >>> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >>> >>> >>> >>> >> >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Htmlparser-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> >> >> > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |
From: Derrick O. <Der...@Ro...> - 2006-06-26 22:14:59
|
I think you need something like this... Parser parser = new Parser (); parser.setInputHtml (html); NodeList list = parser.parse (null); list.visitAllNodesWith (new SegmentReplacingVisitor ()); System.out.println (list.toHtml ()); ...assuming the SegmentReplacingVisitor does the right stuff to the right nodes. Mark Stark wrote: >I dont understand. I've got a html file, manipulate some tags with my >visitor, perhaps change an attribute value. and then? serialize the >toHtml() output into a file and thats it? > >Ian Macfarlane schrieb: > > >>If you do Parser.parse() you get a NodeList, and then if you call the >>toHtml() method it will return a String of the reparsed code. >> >>Ian >> >>On 6/26/06, Mark Stark <htm...@ey...> wrote: >> >> >>>hi, >>> >>>is it possible to change certain stirngs in a html file, without >>>"rebuilding" it? I would like to change some string in a html file, like >>>a dictionary lookup, but i dont want to rebuild the html file like its >>>done in URLModifyingVisitor. >>> >>>Can anybody give me a hint? I've still got >>> >>>Parser p = new Parser(); >>>p.setInputHTML(html); >>>SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >>>p.visitAllNodesWith(s); >>> >>>and do some text.setText() within the SegmentReplacingVisitor each time >>>i visit a StringNode. How to save it into a translated.htm file without >>>rebuilding it? >>> >>>thanks a lot >>> >>> >>>Using Tomcat but need to do more? Need to support web services, security? >>>Get stuff done quickly with pre-integrated technology to make your job easier >>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>>_______________________________________________ >>>Htmlparser-user mailing list >>>Htm...@li... >>>https://lists.sourceforge.net/lists/listinfo/htmlparser-user >>> >>> >>> >>Using Tomcat but need to do more? Need to support web services, security? >>Get stuff done quickly with pre-integrated technology to make your job easier >>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >>_______________________________________________ >>Htmlparser-user mailing list >>Htm...@li... >>https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> >> >> >> > > > >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >Htmlparser-user mailing list >Htm...@li... >https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > > |
From: Mark S. <htm...@ey...> - 2006-06-26 18:35:47
|
I tried to use it this way: Parser p = new Parser(); p.setInputHTML(normalHTML); System.out.println(">>>>>>> "+p.parse(null).toHtml()); TestVisitor s = new TestVisitor(); p.parse(null).visitAllNodesWith(s); System.out.println("<<<<<<<" +p.parse(null).toHtml()); In TestVisitor public void visitStringNode (Text string) { string.setText("XXX"); } The first System.out prints the original html, second System.out prints out nothing but the "<<<<". Have you any suggestions? :) Thanks a lot Ian Macfarlane schrieb: > If you do Parser.parse() you get a NodeList, and then if you call the > toHtml() method it will return a String of the reparsed code. > > Ian > > On 6/26/06, Mark Stark <htm...@ey...> wrote: >> hi, >> >> is it possible to change certain stirngs in a html file, without >> "rebuilding" it? I would like to change some string in a html file, like >> a dictionary lookup, but i dont want to rebuild the html file like its >> done in URLModifyingVisitor. >> >> Can anybody give me a hint? I've still got >> >> Parser p = new Parser(); >> p.setInputHTML(html); >> SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >> p.visitAllNodesWith(s); >> >> and do some text.setText() within the SegmentReplacingVisitor each time >> i visit a StringNode. How to save it into a translated.htm file without >> rebuilding it? >> >> thanks a lot >> >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Htmlparser-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |
From: Mark S. <htm...@ey...> - 2006-06-26 16:54:30
|
I dont understand. I've got a html file, manipulate some tags with my visitor, perhaps change an attribute value. and then? serialize the toHtml() output into a file and thats it? Ian Macfarlane schrieb: > If you do Parser.parse() you get a NodeList, and then if you call the > toHtml() method it will return a String of the reparsed code. > > Ian > > On 6/26/06, Mark Stark <htm...@ey...> wrote: >> hi, >> >> is it possible to change certain stirngs in a html file, without >> "rebuilding" it? I would like to change some string in a html file, like >> a dictionary lookup, but i dont want to rebuild the html file like its >> done in URLModifyingVisitor. >> >> Can anybody give me a hint? I've still got >> >> Parser p = new Parser(); >> p.setInputHTML(html); >> SegmentReplacingVisitor s = new SegmentReplacingVisitor(); >> p.visitAllNodesWith(s); >> >> and do some text.setText() within the SegmentReplacingVisitor each time >> i visit a StringNode. How to save it into a translated.htm file without >> rebuilding it? >> >> thanks a lot >> >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Htmlparser-user mailing list >> Htm...@li... >> https://lists.sourceforge.net/lists/listinfo/htmlparser-user >> > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |
From: Ian M. <ian...@gm...> - 2006-06-26 08:11:06
|
If you do Parser.parse() you get a NodeList, and then if you call the toHtml() method it will return a String of the reparsed code. Ian On 6/26/06, Mark Stark <htm...@ey...> wrote: > hi, > > is it possible to change certain stirngs in a html file, without > "rebuilding" it? I would like to change some string in a html file, like > a dictionary lookup, but i dont want to rebuild the html file like its > done in URLModifyingVisitor. > > Can anybody give me a hint? I've still got > > Parser p = new Parser(); > p.setInputHTML(html); > SegmentReplacingVisitor s = new SegmentReplacingVisitor(); > p.visitAllNodesWith(s); > > and do some text.setText() within the SegmentReplacingVisitor each time > i visit a StringNode. How to save it into a translated.htm file without > rebuilding it? > > thanks a lot > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |
From: Mark S. <htm...@ey...> - 2006-06-26 07:54:29
|
hi, is it possible to change certain stirngs in a html file, without "rebuilding" it? I would like to change some string in a html file, like a dictionary lookup, but i dont want to rebuild the html file like its done in URLModifyingVisitor. Can anybody give me a hint? I've still got Parser p = new Parser(); p.setInputHTML(html); SegmentReplacingVisitor s = new SegmentReplacingVisitor(); p.visitAllNodesWith(s); and do some text.setText() within the SegmentReplacingVisitor each time i visit a StringNode. How to save it into a translated.htm file without rebuilding it? thanks a lot |
From: Ian M. <ian...@gm...> - 2006-06-23 14:14:59
|
Dear Ryan, This was discussed, and even the constructors/methods were hammered out in this dev mailing list about a month or two ago. However I've not had the time to implement it yet. Please feel free to implement the agreed-upon design (or comment on it). Unfortunately it looks like the SourceForge message archives are down for now, so I'll forward you the entire thread to your own address (no need to copy it all here). Best wishes Ian Macfarlane On 6/22/06, Ryan Smith <rs...@li...> wrote: > > <div a=foobar b=aybabtu></div> > <div a=foodbar b=aybabtu></div> > > > Is there a way to use HasAttributeFilter("a","foo") > > But have the value match *NOT EXACT* ? > > Meaning, it would be nice if the value could be a regular expression, so > i could match all attributes with the word "foo" > instead of having to match thte attribute EXACTLY > > Is this possible? can i add a patch? > > > Also, while im at it, the HtmlParserUtils has nice methods like trim > tags etc... > But i use a custom parser with my own tags defined, and the util class > provides no way to give your own parser, (it called new Parser() :( ) > Can support be added to this? ( i have a patch if anyone wants it ) > > > Thanks > -Ryan Smith > Software Developer > Foreclosure.com > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |
From: Ryan S. <rs...@li...> - 2006-06-22 15:00:33
|
<div a=foobar b=aybabtu></div> <div a=foodbar b=aybabtu></div> Is there a way to use HasAttributeFilter("a","foo") But have the value match *NOT EXACT* ? Meaning, it would be nice if the value could be a regular expression, so i could match all attributes with the word "foo" instead of having to match thte attribute EXACTLY Is this possible? can i add a patch? Also, while im at it, the HtmlParserUtils has nice methods like trim tags etc... But i use a custom parser with my own tags defined, and the util class provides no way to give your own parser, (it called new Parser() :( ) Can support be added to this? ( i have a patch if anyone wants it ) Thanks -Ryan Smith Software Developer Foreclosure.com |
From: Ian M. <ian...@gm...> - 2006-06-09 10:19:47
|
Yup, internationalization issues can be pretty confusing :) I've written a test file using windows-1251 source file and windows-specific characters, then changing meta content and headers to find out what happens in my web browser. The case is as follows: - With no charset specified in headers or meta tags, it can't work out the charset - With no charset specified in headers but charset specified in meta tag, the meta tag one is used - When the charset is specified in the headers, it overrides anything specified in the meta tag I'm going to eventaully have to emulate that. I'm pretty sure that the Apache HTTPClient just uses the charset specified in the http headers. It does have a method to get the response charset specified in the headers, but unfortunately it looks like if none is specified it defaults to iso-8859-1 (or whichever is set as default), which means I can't really tell if it's had one set or not. So I think, for now, I'm going to ignore it and see if it turns out to be a problem or not :) Ian On 6/9/06, Derrick Oswald <Der...@ro...> wrote: > Ian, > > Don't you just hate Windows Search - completely broken and it's been > that way for a half dozen years. > But if you complain it doesn't get you anywhere... > > Correct so far. > > - the interpretation of the bytes from the input stream follows the META > tag after that's encountered, > a Java String doesn't really have a charset as far as I can tell - > it's Unicode UTF-16 (I may be wrong here), > so the answer is: it will have the 'correct' charset - whatever set it > last, header or META. > The regenerated toHtml() String will have the 'correct' charset > because it's coming from an array of char > which (as far as I can tell) covers most of the possible charsets. > [I say most because there is a move afoot to make chars int32 in size > to accommodate many more Chinese glyphs etc. > and I'm not sure if that's in Mustang (Java 1.5) or not.] > Now if you want to write an array of bytes on disk or pass a string to > another program with 8 bit chars, > you need to choose an encoding that can accommodate your charset... > whole new ballgame. > Bottom line is the encoding only matters if it's converted to bytes (I > think). > Check out the 'Save As Unicode' option in NotePad, it doesn't ask for > a charset, > (but then again, it may *know* the charset from user settings) > but that sets the encoding (Unicode UTF-8 I think) for the file on disk. > > - in a number of places this is exactly the processing used, reset() > followed by reparse, > see for example StringBean.setStrings () - the point being that the > client *must* rehandle > nodes it was given, usually by starting from scratch - I don't know > any other way - because > what it was given was erroneous. In the case of a String as input, > reparse won't yield any > different characters (they just come from the String via charAt() and > that won't change > because the String is immutable) so the reset is redundant, except > that the StringSource > will have it's encoding (member variable) set correctly the second > time so the hiccup > won't happen twice. But the conversion from the byte stream to a > String has to have > been correct regardless of what the HTTP header says, otherwise you're > pimped. > So if the HttpClient gives you a String you have to ask: > - did it look at the META tag? > - is the META tag correct? > > If it sounds confused, that's because it probably is - in my own mind. > > Derrick > > Ian Macfarlane wrote: > > >That will teach me to rely on windows search. Bleh. > > > >Ok, so if the headers kick the file out as one charset, then the meta > >tag states that it is a different one, I assume (based on the W3C > >recommendations and a quick peek at InputStreamSource) if the new > >encoding is compatible (characters parsed so far are the same) it will > >just reparse the rest of the page with the new charset, otherwise it > >will throw an EncodingChangeException. Am I right so far? > > > >Now if I walk through these two potential paths: > > > >- If the exception is not thrown, is the parsed document encoded with > >the charset specified in the headers or in the meta tag? I.e. if I > >convert it back to a String from a Nodelist etc, will it have the > >correct charset from the meta tag still? > > > >- If the exception is thrown, can I reparse the entire document from > >the original String or would I have to go back to the orignal byte[] > >to do this? > > > >Thanks, > > > >Ian > > > >On 6/7/06, Derrick Oswald <der...@ro...> wrote: > > > > > >>Its thrown in > >> org.htmlparser.lexer.InputStreamSource.setEncoding > >>(String) > >> > >> > >> > >>Ian Macfarlane <ian...@gm...> wrote: > >> > >> Derrick, > >> > >>I can't see anywhere EncodingChangeException is thrown in the code, > >>perhaps this is not implemented yet? > >> > >>Ian > >> > >>On 6/5/06, Derrick Oswald wrote: > >> > >> > >>>Ian, > >>> > >>>If you have a String in Java, it's Unicode encoded in UTF-16 - no? > >>>(the trick of course, is in how it got to be a String, or how the String > >>>gets saved to a Stream) > >>>so I don't think you *need* to specify the encoding if you are passing > >>>in a String. > >>>Looking at the StringSource.java code, the encoding which may be passed > >>>in the constructor is just stored as a property. > >>>It doesn't appear to be used. But if set properly on the constructor it > >>>would avoid a retrace when the META tag is encountered. > >>>You would do something like this: > >>>new Parser (new Lexer (new Page (my_string, my_encoding))) > >>> > >>>There is code in MetaTag.doSemanticAction() to set the page encoding > >>>based on the META tag. > >>>This mechanism wouldn't do anything under the hood if the input is a > >>>String (based on the the fact the StringSource just stores the encoding). > >>>But, if the HttpClient incorrectly converted the stream to a String > >>>based on the HTTP header content type and the META tag actually has the > >>>correct encoding you have a problem (this is the reason for the > >>>EncodingChangeException thrown by the parser). > >>> > >>>Conversion from the parse tree to a String actually just regurgitates > >>>the characters read in, so the charset and encoding don't enter into it > >>>here. > >>> > >>>Submitting the String to be parsed again brings up the same issues as > >>>the first time. > >>> > >>>Derrick > >>> > >>>Ian Macfarlane wrote: > >>> > >>> > >>> > >>>>I have a few questions regarding the best way to perform multiple > >>>>parsing to and from HTML stored as a String and HTMLParser parsed > >>>>(tree) format. > >>>> > >>>>1) Firstly, when first parsing (using Parser not Lexer, I need a > >>>>tree), is there a way to pass it the charset (e.g. UTF-8) that was > >>>>specified in the HTTP headers? Do I need to do this if it is already > >>>>encoded correctly? (I'm using Apache HTTPClient which can convert into > >>>>a Byte[] or a correctly encoded String using the headers found, and > >>>>I'm using the latter option). > >>>> > >>>>2) Once I have done this, I'd want it to be overridden if the Meta > >>>>http-equiv Content-Type gives me a different one. Can the parser > >>>>automatically do this? Or do I have to attempt to read it myself? > >>>> > >>>>3) Now I've got the body tag, and a charset specified either by the > >>>>headers or the meta tag (or if none, a sensible default), I want to > >>>>convert the document back into a String again. Do I need to be > >>>>concerned about the charset again here, or do the Node/NodeList > >>>>toString methods handle this? > >>>> > >>>>4) Finally, once I have a String that's a product of the above, and I > >>>>want to again convert it into an HTMLParser tree, do I need to specify > >>>>the charset again here? > >>>> > >>>>Thanks > >>>> > >>>>Ian > >>>> > >>>> > >>>> > > > > > > > > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > |