ä»äºã§ Jython ã使ãæ©ä¼ããã£ã¦
ã»ã¼ãåã㦠Jython ã触ã£ããã§ããã©ããã£ã¡ããããããã
Java ã®ã¯ã©ã¹ãä½ãèããã«ä½¿ãã¡ããã
ãã¨ãã°ã HTML (not XHTML) ããã¼ã¹ã㦠XPath ã§åå¾ããã³ã¼ãã¨ãã nekohtml 㨠xalan ã§ä»¥ä¸ã®ããã«æ¸ãã
from java.io import FileInputStream from org.xml.sax import InputSource from org.cyberneko.html.parsers import DOMParser from org.apache.xpath import XPathAPI # input source = InputSource(FileInputStream('test.html')) source.setEncoding('UTF-8') # parse parser = DOMParser() parser.parse(source) doc = parser.getDocument() # xpath evaluate print XPathAPI.selectNodeList(doc, '/HTML/BODY/*').item(0)
ã»ãã¨æ¥½ã« Java ã®ã¯ã©ã¹ã使ãã¦æåããã
ã¦ãããã®ãµã³ãã« java ã®ã¯ã©ã¹ä»¥å¤ä½¿ã£ã¦ãªãã£ã¦ããã
å¾ã¯ id:nishiohirokazu ã® Jython æ¬ãè²·ãã°å®ç§ã§ããï¼