{"id":2723,"date":"2016-08-05T08:35:31","date_gmt":"2016-08-04T23:35:31","guid":{"rendered":"http:\/\/blog.rutake.com\/techmemo\/?p=2723"},"modified":"2016-08-05T08:35:31","modified_gmt":"2016-08-04T23:35:31","slug":"htmlunit-%e6%96%87%e5%ad%97%e5%88%97%e3%81%8b%e3%82%89htmlpage%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.rutake.com\/techmemo\/2016\/08\/05\/htmlunit-%e6%96%87%e5%ad%97%e5%88%97%e3%81%8b%e3%82%89htmlpage%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b\/","title":{"rendered":"HTMLUnit \u6587\u5b57\u5217\u304b\u3089HTMLPage\u3092\u4f5c\u6210\u3059\u308b"},"content":{"rendered":"<p>\u30c7\u30d0\u30c3\u30b0\u306e\u3068\u304d\u306b\u3044\u3061\u3044\u3061\u30ea\u30e2\u30fc\u30c8\u306b\u3064\u306a\u3050\u306e\u306f\u52b9\u7387\u304c\u60aa\u3044\u306e\u3067\u3001String\u304b\u3089HTMLPage\u3092\u751f\u6210\u3059\u308b\u65b9\u6cd5<\/p>\n<p>[java]<br \/>\nimport java.io.IOException;<br \/>\nimport java.net.URL;<\/p>\n<p>import com.gargoylesoftware.htmlunit.StringWebResponse;<br \/>\nimport com.gargoylesoftware.htmlunit.WebClient;<br \/>\nimport com.gargoylesoftware.htmlunit.html.HTMLParser;<br \/>\nimport com.gargoylesoftware.htmlunit.html.HtmlPage;<\/p>\n<p>public class HtmlUnitTest {<\/p>\n<p>\tpublic static void main(String[] args) throws IOException {<br \/>\n\t\t\/\/ TODO Auto-generated method stub<br \/>\n\t\tURL url = new URL(&#8220;http:\/\/www.example.com&#8221;);<br \/>\n\t    StringWebResponse response = new StringWebResponse(&#8220;<html><head><title>Test<\/title><\/head><body><\/body><\/html>&#8220;, url);<br \/>\n\t    WebClient webClient = new WebClient();<br \/>\n\t    HtmlPage page = HTMLParser.parseHtml(response, webClient.getCurrentWindow());<br \/>\n\t    System.out.println(page.getTitleText());<br \/>\n\t    webClient.close();<br \/>\n\t}<\/p>\n<p>}<br \/>\n[\/java]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c7\u30d0\u30c3\u30b0\u306e\u3068\u304d\u306b\u3044\u3061\u3044\u3061\u30ea\u30e2\u30fc\u30c8\u306b\u3064\u306a\u3050\u306e\u306f\u52b9\u7387\u304c\u60aa\u3044\u306e\u3067\u3001String\u304b\u3089HT &hellip; <a href=\"https:\/\/blog.rutake.com\/techmemo\/2016\/08\/05\/htmlunit-%e6%96%87%e5%ad%97%e5%88%97%e3%81%8b%e3%82%89htmlpage%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[524],"_links":{"self":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2723"}],"collection":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/comments?post=2723"}],"version-history":[{"count":1,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2723\/revisions"}],"predecessor-version":[{"id":2724,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2723\/revisions\/2724"}],"wp:attachment":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/media?parent=2723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/categories?post=2723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/tags?post=2723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}