{"id":54433,"date":"2020-04-09T03:21:15","date_gmt":"2020-04-08T19:21:15","guid":{"rendered":"http:\/\/4563.org\/?p=54433"},"modified":"2020-04-09T03:21:15","modified_gmt":"2020-04-08T19:21:15","slug":"%e5%8f%ae%e5%92%9a%e7%88%ac%e8%99%ab-2","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=54433","title":{"rendered":"\u53ee\u549a\u722c\u866b"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3>\u53ee\u549a\u722c\u866b<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 yjsx86 \u4e8e 2020-4-6 00:16 \u7f16\u8f91 <\/p>\n<p> \u539f\u5e16: https:\/\/www.hostloc.com\/thread-669605-1-1.html<br \/>  \u53ea\u722c\u4e86\u5b8c\u672c\u7684!<br \/>  \u4f30\u8ba1\u5927\u591a\u6570\u4eba\u6ca1\u6709yaml\u5e93 pip install pyyaml<br \/>  \u6211\u8349 \u6211\u521a\u624d\u628a\u6211\u7684\u8d26\u53f7\u5bc6\u7801\u5199\u5728\u4ee3\u7801\u91cc\u4e86, \u867d\u7136\u662f\u6d4b\u8bd5\u7528\u8d26\u53f7<br \/>  import requests, yaml, os, logging<\/p>\n<p>  root = os.path.dirname(__file__)<br \/>  logging.basicConfig(level=logging.INFO, format=&#8217;%(asctime)s &#8211; %(levelname)s &#8211; %(message)s&#8217;)<br \/>  session = requests.session()<\/p>\n<p>  def login(u, p):<br \/>  &nbsp; &nbsp; if u == &quot;&quot; or p == &quot;&quot;:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(&quot;\u8bf7\u586b\u5199: user pwd&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;exit(1)<br \/>  &nbsp; &nbsp; url = f&quot;https:\/\/www.meto3517.com\/user\/login?userName={u}&amp;password={p}&quot;<br \/>  &nbsp; &nbsp; r = session.get(url).json()<br \/>  &nbsp; &nbsp; if r[&quot;msg&quot;] == &quot;\u767b\u9304\u6210\u529f&quot;:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(&quot;\u767b\u9646\u6210\u529f&quot;)<br \/>  &nbsp; &nbsp; else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(&quot;\u767b\u9646\u5931\u8d25!&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;exit(1)<\/p>\n<p>  def completedBooks():<br \/>  &nbsp; &nbsp; print(&quot;\u83b7\u53d6\u5b8c\u672cID&#8220;`&quot;)<br \/>  &nbsp; &nbsp; url = &quot;https:\/\/www.meto3517.com\/query\/books?ranking=wjb&amp;paged=true&amp;size=100&amp;page=1&amp;type=cartoon&quot;<br \/>  &nbsp; &nbsp; r = session.get(url).json()<br \/>  &nbsp; &nbsp; books = r[&quot;content&quot;][&quot;list&quot;]<br \/>  &nbsp; &nbsp; return books<\/p>\n<p>  def getBookChapters(id):<br \/>  &nbsp; &nbsp; url = f&quot;https:\/\/www.meto3517.com\/query\/book\/directory?bookId={id}&quot;<br \/>  &nbsp; &nbsp; r = session.get(url).json()<br \/>  &nbsp; &nbsp; return r[&quot;content&quot;]<\/p>\n<p>  def writeYamlFile(obj, bookpath):<br \/>  &nbsp; &nbsp; yamlpath = os.path.join(bookpath, &quot;info.yaml&quot;)<br \/>  &nbsp; &nbsp; with open(yamlpath, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;yaml.dump(obj, f, allow_unicode=True)<\/p>\n<p>  def getImgBinaryContent(imgurl):<br \/>  &nbsp; &nbsp; r = session.get(imgurl)<br \/>  &nbsp; &nbsp; return r.content<\/p>\n<p>  def downloadImgs(chapter, chapterpath):<br \/>  &nbsp; &nbsp; url = f&quot;https:\/\/www.meto3517.com\/query\/book\/chapter?bookId={chapter[&#8216;bookId&#8217;]}&amp;chapterId={chapter[&#8216;id&#8217;]}&quot;<br \/>  &nbsp; &nbsp; r = session.get(url).json()<br \/>  &nbsp; &nbsp; imglist = r[&quot;content&quot;][&quot;imageList&quot;]<br \/>  &nbsp; &nbsp; for img in imglist:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;imgurl = img[&quot;url&quot;]<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;imgName = img[&quot;encodeName&quot;].split(&quot;_&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;imgext = img[&quot;encodeName&quot;].split(&quot;.&quot;)[-1]<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;imgFullName = f&quot;{imgName}.{imgext}&quot;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;imgpath = os.path.join(chapterpath, imgFullName)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;with open(imgpath, &quot;wb&quot;) as f:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;f.write(getImgBinaryContent(imgurl))<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;logging.info(f&#8217;&nbsp; &nbsp; -&gt; {imgFullName} ok!&#8217;)<\/p>\n<p>  def downloadChapter(chapter, bookpath):<br \/>  &nbsp; &nbsp; logging.info(f&#8217;&nbsp; &nbsp; -&gt; {chapter[&quot;title&quot;]}&#8217;)<br \/>  &nbsp; &nbsp; chapterpath = os.path.join(bookpath, chapter[&quot;title&quot;])<br \/>  &nbsp; &nbsp; os.mkdir(chapterpath)<br \/>  &nbsp; &nbsp; downloadImgs(chapter, chapterpath)<\/p>\n<p>  def downloadBook(id):<br \/>  &nbsp; &nbsp; url = f&quot;https:\/\/www.meto3517.com\/query\/book?id={id}&quot;<br \/>  &nbsp; &nbsp; r = session.get(url).json()<br \/>  &nbsp; &nbsp; logging.info(f&#8217;\u4e0b\u8f7d -&gt; {r[&quot;content&quot;][&quot;name&quot;]}&#8217;)<br \/>  &nbsp; &nbsp; obj = {}<br \/>  &nbsp; &nbsp; obj[&quot;name&quot;] = r[&quot;content&quot;][&quot;name&quot;]<br \/>  &nbsp; &nbsp; obj[&quot;author&quot;] = r[&quot;content&quot;][&quot;author&quot;]<br \/>  &nbsp; &nbsp; obj[&quot;description&quot;] = r[&quot;content&quot;][&quot;description&quot;]<br \/>  &nbsp; &nbsp; obj[&quot;tags&quot;] = r[&quot;content&quot;][&quot;tags&quot;]<br \/>  &nbsp; &nbsp; bookpath = os.path.join(root, obj[&quot;name&quot;])<br \/>  &nbsp; &nbsp; os.mkdir(bookpath)<br \/>  &nbsp; &nbsp; writeYamlFile(obj, bookpath)<br \/>  &nbsp; &nbsp; chapters = getBookChapters(id)<br \/>  &nbsp; &nbsp; for chapter in chapters:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;downloadChapter(chapter, bookpath)<\/p>\n<p>  if __name__ == &#8216;__main__&#8217;:<br \/>  &nbsp; &nbsp; # \u7528\u6237\u540d \u5bc6\u7801<br \/>  &nbsp; &nbsp; user = &quot;&quot;<br \/>  &nbsp; &nbsp; pwd = &quot;&quot;<br \/>  &nbsp; &nbsp; login(user, pwd)<br \/>  &nbsp; &nbsp; books = completedBooks()<br \/>  &nbsp; &nbsp; for book in books:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;downloadBook(book[&quot;id&quot;])\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>flofire<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 flofire \u4e8e 2020-4-6 01:41 \u7f16\u8f91 <\/p>\n<p> php\u591a\u7ebf\u7a0b\u7248\u3001\u5931\u8d25\u81ea\u52a8\u91cd\u8bd5\uff0c\u770breadme\u540e\u8fd0\u884c\u3002<br \/>  \u5e0c\u671b\u5e2e\u5230\u6709\u9700\u8981\u7684\u4eba\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u71d5\u5341\u4e09\u4e36<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u611f\u8c22\u5206\u4eab&nbsp; &nbsp;\u62ff\u8d70\u4e86 \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>b66667777<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5e2e\u9876\u4e00\u4e0b\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>jmmes<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u7b491\u5065\u8f6c\u5b58:lol\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u71d5\u5341\u4e09\u4e36 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-4-5 21:23<br \/>  \u611f\u8c22\u5206\u4eab&nbsp; &nbsp;\u62ff\u8d70\u4e86<\/p>\n<p> w cao \u5bc6\u7801\u6211\u90fd\u5199\u4e0a\u4e86\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>ficefox<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5927\u4f6c \u4f60\u592a\u5feb\u4e86  \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>egihosting99<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5e26\u8d70\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>Yrh<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u62ff\u8d70\u62ff\u8d70\uff0c\u611f\u8c22\u5927\u4f6c\uff0c\u4eca\u665a\u4e0d\u7761\u4e86:lol:lol:lol\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>yjsx86<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\tficefox \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-4-5 21:25<br \/>  \u5927\u4f6c \u4f60\u592a\u5feb\u4e86<\/p>\n<p> \u4e3b\u8981\u662f \u4ee3\u7801\u4e00\u904d\u8fc7, \u57fa\u672c\u6ca1\u4fee\u6539\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>lunatic<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5927\u4f6c\u725b\u6279\uff0cPY\u8d5b\u9ad8\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>yjsx86 \u5927\u4f6c\u6709\u8bdd\u8bf4 : \u53ee\u549a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/54433"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54433"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/54433\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=54433"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=54433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}