├── LICENSE ├── README.md └── huaban ├── clojure-crawler ├── .gitignore ├── .idea │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── libraries │ │ ├── Leiningen__clojure_complete_0_2_4.xml │ │ ├── Leiningen__http_kit_2_2_0.xml │ │ ├── Leiningen__org_clojure_clojure_1_7_0.xml │ │ ├── Leiningen__org_clojure_data_json_0_2_6.xml │ │ └── Leiningen__org_clojure_tools_nrepl_0_2_12.xml │ ├── misc.xml │ ├── modules.xml │ ├── replstate.xml │ └── workspace.xml ├── LICENSE ├── README.md ├── clojure-crawler.iml ├── doc │ └── intro.md ├── project.clj ├── src │ └── clojure_crawler │ │ └── core.clj └── test │ └── clojure_crawler │ └── core_test.clj └── python └── HuabanCrawler.py /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Crawler-Demo 2 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | /image 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ 13 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/libraries/Leiningen__clojure_complete_0_2_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/libraries/Leiningen__http_kit_2_2_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/libraries/Leiningen__org_clojure_clojure_1_7_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/libraries/Leiningen__org_clojure_data_json_0_2_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/libraries/Leiningen__org_clojure_tools_nrepl_0_2_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 1.8 28 | 29 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/replstate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | {:repl-history {:ide [], :local ["(def a main1)" "(def a main)" "(promise? a)" "(def a '(1 2 3))" "(map println a)" "(map #(%) a)" "(map #((+ 1 %)) a)" "(map #(+ 1 %) a)" "(def b (map #(+ 1 %) a))" "b" "(def a (take 10 (iterate 1)))" "(def a (take 10 iterate 1))" "(def a (take 10 (iterate inc 1)))" "(type a (main1))" "(def a (main1))" "(def a (take 100 (iterate inc 1)))" "(def b (map inc a))" "(def b (get-body))" "(type b)" "(take 10 @b)" "(def a(main2))" "(def a ())" "(def a (main2))" "(main2 println)" "(def a (main2 proc))" "(type a)" "(first a)" "(take 2 a)" "(def a (http/get http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options))" "(def a (http/get \"http://www.baidu.com\"))" "(def a (http/get \"http://www.baidu.com\") options)" "(def a (http/get \"http://www.baidu.com\" options))" "(def a (http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options))" "a" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys body}] (proc get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys body}] (println get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body]}] (proc get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body]}] (print get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] ((println body) (println status))))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] (do (println body) (println status))))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] (do (proc body) (println status))))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] (do (process body) (println status))))" "(defn callback [{:keys [status headers body error opts]}]\n ;; opts contains :url :method :header + user defined key(s)\n (let [{:keys [method start-time url]} opts]\n (println method url \"status\" status \"takes time\"\n (- (System/currentTimeMillis) start-time) \"ms\")))\n\n;;; save state for callback, useful for async request\n(let [opts {:start-time (System/currentTimeMillis)}]\n (http/get \"http://http-kit.org\" opts callback))" "(defn callback [{:keys [status headers body error opts]}]\n ;; opts contains :url :method :header + user defined key(s)\n (let [{:keys [method body start-time url]} opts]\n (println method url \"status\" status \"takes time\" body\n (- (System/currentTimeMillis) start-time) \"ms\")))\n\n;;; save state for callback, useful for async request\n(let [opts {:start-time (System/currentTimeMillis)}]\n (http/get \"http://http-kit.org\" opts callback))" "(main1)" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" {:as :text} options\n (fn [{:keys [status body error]}]\n (if error\n (println \"Failed\")\n (println body))))" "\n(def a main1)" "(proc main2)" "(def a (main3))" "(take 20 a)" "(main2 str2json)" "(main2 proc)" "(def info (main2 str2json))" "(take 20 info)" "(take 1 info)" "(second (second info))" "(map println (second (second info)))" "(map (fn [a] (let [k (:key (:file a))] ({:url (str k)}))) (second (second info)))" "(map (fn [a] (let [k (:pin_id a)] ({:url (str k)}))) (second (second info)))" "(map println (take 1 (second (second info))))" "(map (fn [a] (let [k (:seq a)] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:pin_id a)] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:file a)] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a))] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k a))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k n))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k n))) (take 10 (second (second info))))" "(def tt (map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k n))) (take 10 (second (second info)))))" "(def tt (map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] ({:k k :n n}))) (take 10 (second (second info)))))" "tt" "(println tt)" "(main)"], :remote []}} 4 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 57 | 58 | 59 | 64 | 65 | 66 | 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | {:repl-history {:ide [], :local ["(def a main1)" "(def a main)" "(promise? a)" "(def a '(1 2 3))" "(map println a)" "(map #(%) a)" "(map #((+ 1 %)) a)" "(map #(+ 1 %) a)" "(def b (map #(+ 1 %) a))" "b" "(def a (take 10 (iterate 1)))" "(def a (take 10 iterate 1))" "(def a (take 10 (iterate inc 1)))" "(type a (main1))" "(def a (main1))" "(def a (take 100 (iterate inc 1)))" "(def b (map inc a))" "(def b (get-body))" "(type b)" "(take 10 @b)" "(def a(main2))" "(def a ())" "(def a (main2))" "(main2 println)" "(def a (main2 proc))" "(type a)" "(first a)" "(take 2 a)" "(def a (http/get http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options))" "(def a (http/get \"http://www.baidu.com\"))" "(def a (http/get \"http://www.baidu.com\") options)" "(def a (http/get \"http://www.baidu.com\" options))" "(def a (http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options))" "a" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys body}] (proc get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys body}] (println get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body]}] (proc get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body]}] (print get-body)))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] ((println body) (println status))))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] (do (println body) (println status))))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] (do (proc body) (println status))))" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" options (fn [{:keys [body status]}] (do (process body) (println status))))" "(defn callback [{:keys [status headers body error opts]}]\n ;; opts contains :url :method :header + user defined key(s)\n (let [{:keys [method start-time url]} opts]\n (println method url \"status\" status \"takes time\"\n (- (System/currentTimeMillis) start-time) \"ms\")))\n\n;;; save state for callback, useful for async request\n(let [opts {:start-time (System/currentTimeMillis)}]\n (http/get \"http://http-kit.org\" opts callback))" "(defn callback [{:keys [status headers body error opts]}]\n ;; opts contains :url :method :header + user defined key(s)\n (let [{:keys [method body start-time url]} opts]\n (println method url \"status\" status \"takes time\" body\n (- (System/currentTimeMillis) start-time) \"ms\")))\n\n;;; save state for callback, useful for async request\n(let [opts {:start-time (System/currentTimeMillis)}]\n (http/get \"http://http-kit.org\" opts callback))" "(main1)" "(http/get \"http://huaban.com/favorite/beauty/?is07k6hx&max=824270409&limit=20&wfl=1\" {:as :text} options\n (fn [{:keys [status body error]}]\n (if error\n (println \"Failed\")\n (println body))))" "\n(def a main1)" "(proc main2)" "(def a (main3))" "(take 20 a)" "(main2 str2json)" "(main2 proc)" "(def info (main2 str2json))" "(take 20 info)" "(take 1 info)" "(second (second info))" "(map println (second (second info)))" "(map (fn [a] (let [k (:key (:file a))] ({:url (str k)}))) (second (second info)))" "(map (fn [a] (let [k (:pin_id a)] ({:url (str k)}))) (second (second info)))" "(map println (take 1 (second (second info))))" "(map (fn [a] (let [k (:seq a)] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:pin_id a)] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:file a)] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a))] (println k))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k a))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k n))) (take 1 (second (second info))))" "(map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k n))) (take 10 (second (second info))))" "(def tt (map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] (println k n))) (take 10 (second (second info)))))" "(def tt (map (fn [a] (let [k (:key (:file a)) n (:pin_id a)] ({:k k :n n}))) (take 10 (second (second info)))))" "tt" "(println tt)" "(main)"], :remote []}} 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 124 | 125 | 126 | 143 | 144 | 145 | 161 | 162 | 169 | 170 | 171 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 211 | 214 | 216 | 217 | 218 | 219 | 220 | 221 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 281 | 282 | 283 | 294 | 295 | 296 | 306 | 307 | 314 | 315 | 316 | 317 | 335 | 342 | 343 | 344 | 345 | 363 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 1471566364576 399 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 441 | 444 | 445 | 446 | 448 | 449 | 450 | 452 | 453 | 454 | 455 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/README.md: -------------------------------------------------------------------------------- 1 | # clojure-crawler 2 | 3 | 使用Clojure抓取花瓣网美女标签下的图片 4 | 5 | 6 | ## Usage 7 | 8 | $ lein run [page-nums] 9 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/clojure-crawler.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to clojure-crawler 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/project.clj: -------------------------------------------------------------------------------- 1 | (defproject clojure-crawler "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.7.0"] 7 | [org.clojure/data.json "0.2.6"] 8 | [http-kit "2.2.0"]] 9 | :main ^:skip-aot clojure-crawler.core 10 | :target-path "target/%s" 11 | :profiles {:uberjar {:aot :all}}) 12 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/src/clojure_crawler/core.clj: -------------------------------------------------------------------------------- 1 | (ns clojure-crawler.core 2 | (:require [org.httpkit.client :as http] 3 | [clojure.java.io :as io] 4 | [clojure.data.json :as json]) 5 | (:gen-class)) 6 | 7 | (def image-save-path "./image/") 8 | 9 | (defn str2json 10 | "将json字符串转换为字典" 11 | [body] 12 | (json/read-str body :key-fn keyword)) 13 | 14 | (defn get-home-page 15 | "请求首页内容" 16 | [] 17 | (let [options {:timeout 1000 18 | :as :text} 19 | url "http://huaban.com/favorite/beauty/" 20 | {:keys [body]} @(http/get url)] 21 | body)) 22 | 23 | (defn get-image-info 24 | "从首页内容得到图片信息" 25 | [page] 26 | (subs (re-find (re-matcher #"page\[\"pins\"\].*;" page)) 15)) 27 | 28 | (defn download-image 29 | "将图片保存在本地" 30 | [url file-name] 31 | (println (str "download " url)) 32 | (with-open [in (io/input-stream url) 33 | out (io/output-stream file-name)] 34 | (io/copy in out))) 35 | 36 | (defn make-image-url 37 | "根据key值得到图片真实地址" 38 | [k] 39 | (str "http://hbimg.b0.upaiyun.com/" k "_fw658")) 40 | 41 | (defn make-file-name 42 | [file-name] 43 | (str image-save-path file-name ".jpg")) 44 | 45 | (defn download-images 46 | "根据json字符串下载图片" 47 | [jsons] 48 | (dorun (map (fn [a] 49 | (let [k (:key (:file a)) file-name (:pin_id a)] 50 | (download-image (make-image-url k) (make-file-name file-name)))) 51 | jsons)) 52 | (:pin_id (last jsons))) 53 | 54 | (defn download-home-page 55 | "下载首页图片" 56 | [] 57 | (-> (get-home-page) 58 | get-image-info 59 | str2json 60 | download-images)) 61 | 62 | (defn make-json-request-url 63 | "根据pin值创建Ajax请求url" 64 | [pin] 65 | (str "http://huaban.com/favorite/beauty/?is07k6hx&max=" pin "&limit=20&wfl=1")) 66 | 67 | (defn get-more-page 68 | "加载Ajax请求" 69 | [last-pin] 70 | (let [options {:timeout 1000 71 | :as :text 72 | :headers {"Accept" "application/json" 73 | "X-Requested-With" "XMLHttpRequest" 74 | "X-Request" "JSON"}} 75 | {:keys [body]} @(http/get (make-json-request-url last-pin) options)] 76 | body)) 77 | 78 | (defn download-more 79 | "下载通过Ajax异步加载的图片" 80 | [last-pin] 81 | (-> last-pin 82 | get-more-page 83 | str2json 84 | second 85 | second 86 | download-images)) 87 | 88 | (defn main 89 | "下载指定页数的图片,如果不指定页数,下载首页图片" 90 | ([] 91 | (download-home-page) 92 | (println "Finished")) 93 | ([page-num] 94 | (if (> 1 page-num) 95 | (download-home-page) 96 | (letfn [(down-more 97 | [pin n] 98 | (if (zero? n) 99 | (println "Finished!") 100 | (recur (download-more pin) (dec n))))] 101 | (down-more (download-home-page) (- page-num 1)))))) 102 | 103 | (defn -main 104 | "下载花瓣网美女标签下的图片" 105 | [& args] 106 | (if (nil? args) 107 | (main) 108 | (main (read-string (first args))))) 109 | -------------------------------------------------------------------------------- /huaban/clojure-crawler/test/clojure_crawler/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns clojure-crawler.core-test 2 | (:require [clojure.test :refer :all] 3 | [clojure-crawler.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /huaban/python/HuabanCrawler.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # @author: cc 4 | 5 | import requests 6 | import re 7 | import os 8 | import os.path 9 | 10 | class HuabanCrawler(): 11 | """ 抓去花瓣网上的图片 """ 12 | 13 | def __init__(self): 14 | """ 在当前文件夹下新建images文件夹存放抓取的图片 """ 15 | self.homeUrl = "http://huaban.com/favorite/beauty/" 16 | self.images = [] 17 | if not os.path.exists('./images'): 18 | os.mkdir('./images') 19 | 20 | def __load_homePage(self): 21 | """ 加载主页面 """ 22 | return requests.get(url = self.homeUrl).content 23 | 24 | def __make_ajax_url(self, No): 25 | """ 返回ajax请求的url """ 26 | return self.homeUrl + "?i5p998kw&max=" + No + "&limit=20&wfl=1" 27 | 28 | def __load_more(self, maxNo): 29 | """ 刷新页面 """ 30 | return requests.get(url = self.__make_ajax_url(maxNo)).content 31 | 32 | def __process_data(self, htmlPage): 33 | """ 从html页面中提取图片的信息 """ 34 | prog = re.compile(r'app\.page\["pins"\].*') 35 | appPins = prog.findall(htmlPage) 36 | # 将js中的null定义为Python中的None 37 | null = None 38 | true = True 39 | if appPins == []: 40 | return None 41 | result = eval(appPins[0][19:-1]) 42 | for i in result: 43 | info = {} 44 | info['id'] = str(i['pin_id']) 45 | info['url'] = "http://img.hb.aicdn.com/" + i["file"]["key"] + "_fw658" 46 | if 'image' == i["file"]["type"][:5]: 47 | info['type'] = i["file"]["type"][6:] 48 | else: 49 | info['type'] = 'NoName' 50 | self.images.append(info) 51 | 52 | def __save_image(self, imageName, content): 53 | """ 保存图片 """ 54 | with open(imageName, 'wb') as fp: 55 | fp.write(content) 56 | 57 | def get_image_info(self, num=20): 58 | """ 得到图片信息 """ 59 | self.__process_data(self.__load_homePage()) 60 | for i in range((num-1)/20): 61 | self.__process_data(self.__load_more(self.images[-1]['id'])) 62 | return self.images 63 | 64 | def down_images(self): 65 | """ 下载图片 """ 66 | print "{} image will be download".format(len(self.images)) 67 | for key, image in enumerate(self.images): 68 | print 'download {0} ...'.format(key) 69 | try: 70 | req = requests.get(image["url"]) 71 | except : 72 | print 'error' 73 | imageName = os.path.join("./images", image["id"] + "." + image["type"]) 74 | self.__save_image(imageName, req.content) 75 | 76 | 77 | if __name__ == '__main__': 78 | hc = HuabanCrawler() 79 | hc.get_image_info(200) 80 | hc.down_images() 81 | --------------------------------------------------------------------------------