{"id":61,"date":"2014-06-24T04:55:03","date_gmt":"2014-06-24T04:55:03","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=61"},"modified":"2014-06-24T04:55:03","modified_gmt":"2014-06-24T04:55:03","slug":"%e8%bd%ac%e7%94%a8js%e7%9a%84%e6%96%b9%e5%bc%8f%e9%87%87%e9%9b%86google%e7%9a%84url","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/61.html","title":{"rendered":"[collect]\u7528js\u7684\u65b9\u5f0f\u91c7\u96c6Google\u7684URL"},"content":{"rendered":"<h5>Google hack-\u7b80\u5355\u9875\u9762URL\u91c7\u96c6<\/h5>\n<p><span style=\"color: #ff0000;\">\u91c7\u96c6Google\u7684URL\u65b9\u5f0f\u591a\u91cd\u591a\u6837\uff0c\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u83ab\u8fc7\u4e8ejs\u76f4\u63a5\u83b7\u53d6\u8282\u70b9\u4e86\u3002<\/span>\u6bd4\u5982\uff1a<\/p>\n<pre class=\"lang:js decode:true\">var h3 = document.getElementsByTagName('h3');\nfor(var i=0;i&lt;h3.length;i++){\n    var a = h3[i]. getElementsByTagName('a');\n    console.log(a[0].href);\n}<\/pre>\n<p>\u5728Chrome\u6d4f\u89c8\u5668\u4e2d\uff0c\u6309\u4e0bF12\u6253\u5f00\u5176\u4e2d\u7684\u201cConsole\u201d\uff0c\u7136\u540e\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u8d34\u5165\uff0c\u6309\u4e0bEnter\u952e\u6267\u884c\u5373\u53ef\u770b\u5230\u6548\u679c\u3002<\/p>\n<h6>\u5728java\u91cc\u9762\u7528jsoup\u4e5f\u53ef\u4ee5\u975e\u5e38\u7b80\u5355\u7684\u83b7\u53d6\u5230\u641c\u7d22\u7ed3\u679c\u7684URL\uff1a<\/h6>\n<pre class=\"lang:java decode:true\">public static void main(String[] args) throws IOException {\n\tDocument doc = Jsoup.connect(\"https:\/\/www.google.ws\/search?num=100&amp;site=&amp;source=hp&amp;q=filetype%3Ajsp&amp;oq=filetype%3Ajsp&amp;gs_l=hp.3...8115.14780.0.15194.22.21.1.0.0.0.523.5187.3j3j3j5j4j1.19.0....0...1c.1.36.hp..14.8.1440.P_2EQhc7Pz0\").userAgent(\"Googlebot\/2.1 (+http:\/\/www.googlebot.com\/bot.html)\").timeout(5000).get();\n\tElements element = doc.getElementsByTag(\"h3\");\n\tfor (Element e : element) {\n\t\tMatcher m= Pattern.compile(\"\/url\\?q=(.*)&amp;sa\").matcher(e.getElementsByTag(\"a\").get(0).attr(\"href\"));\n\t\tif(m.find()){\n\t\t\tSystem.out.println(URLDecoder.decode(m.group(1),\"UTF-8\"));\n\t\t}\n\t}\n}<\/pre>\n<h6>\u6b63\u5219\u7684\u65b9\u5f0f\uff1a<\/h6>\n<pre class=\"lang:java decode:true \">package org.javaweb.test;\n\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\npublic class TestReg {\n\n    public static void main(String[] args) {\n        String source=\"&lt;h3 class=\"r\"&gt;&lt;a href=\"http:\/\/baidu.com\"&gt;\u767e\u5ea6&lt;\/a&gt;&lt;\/h3&gt;&lt;h3 class=\"r\"&gt;&lt;a href=\"http:\/\/google.com\"&gt;\u8c37\u6b4c&lt;\/a&gt;&lt;\/h3&gt; \";\n        StringBuilder resultComment=new StringBuilder();\n        StringBuilder resultName=new StringBuilder();\n        System.out.println(\"=======\u5f00\u59cb\u5339\u914d========\");\n        String patternStrs=\"(&lt;h3 class=\"r\"&gt;&lt;a.+?)href=\"(.+?)\"&gt;(.+?)(&lt;\/a&gt;&lt;\/h3&gt;)\";\n        Pattern pattern=Pattern.compile(patternStrs);\n        Matcher matcher=pattern.matcher(source);\n        while(matcher.find()){\n            resultName.append(matcher.group(2)+\"n\");\n            resultComment.append(matcher.group(3)+\"n\");\n        }\n        System.out.println(\"=======\u6807\u7b7e\u5185\u5185\u5bb9=======\");\n        System.out.println(resultComment.toString());\n        System.out.println(\"=======name\u5c5e\u6027\u503c=======\");\n        System.out.println(resultName.toString());\n    }\n}<\/pre>\n<h6>\u539f\u6587\u94fe\u63a5\uff1a<\/h6>\n<p><a title=\"google hack-\u7b80\u5355\u9875\u9762URL\u91c7\u96c6\" href=\"http:\/\/p2j.cn\/?p=807\" target=\"_blank\">http:\/\/p2j.cn\/?p=807<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google hack-\u7b80\u5355\u9875\u9762URL\u91c7\u96c6 \u91c7\u96c6Google\u7684URL\u65b9\u5f0f\u591a\u91cd\u591a\u6837\uff0c\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u83ab\u8fc7\u4e8ejs\u76f4\u63a5\u83b7 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[41,61,62],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-tools","tag-google","tag-java","tag-javascript"],"views":4503,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}