{"id":18103,"date":"2020-02-04T22:08:09","date_gmt":"2020-02-04T14:08:09","guid":{"rendered":"http:\/\/4563.org\/?p=18103"},"modified":"2020-02-04T22:08:09","modified_gmt":"2020-02-04T14:08:09","slug":"u-file%e5%88%a9%e7%94%a8","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=18103","title":{"rendered":"u-file\u5229\u7528"},"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>u-file\u5229\u7528<\/h3>\n<p>  \t\t\u4e4b\u524d\u6ce8\u518c\u4e86u-file\u4f46\u662f\u4e00\u76f4\u6ca1\u7528<br \/>  \u4eca\u5929\u8981\u628a\u5176\u4e2d\u4e00\u4e2a\u6587\u4ef6\u5206\u4eab\u7ed9\u670b\u53cb\uff0c \u4e45\u6ca1\u7528\u5fd8\u4e86\u5177\u4f53\u4f4d\u7f6e\uff0c \u7136\u540e\u767b\u5f55flashfxp\u627e\u6587\u4ef6\u7136\u540e\u62fc\u63a5url\u518d\u7ed9\u670b\u53cb<br \/>  \u611f\u89c9\u6709\u70b9\u9ebb\u70e6 \u5c31\u4ea7\u751f\u4e86\u8fd9\u4e2a\u811a\u672c<br \/>  \u5177\u4f53\u4f5c\u7528\u5462\u5c31\u662f\u904d\u5386\u6587\u4ef6\uff0c \u7136\u540e\u751f\u6210html\u4e0a\u4f20<br \/>  \u6548\u679c\u89c1\uff1ahttp:\/\/files.baicailou.com<br \/>  import ftplib<br \/>  import re<\/p>\n<p>  addr_ftp = &quot;box.u-file.cn&quot;<br \/>  # \u7528\u6237\u540d<br \/>  username = &quot;?????????????????&quot;<br \/>  # \u5bc6\u7801<br \/>  password = &quot;?????????????????&quot;<\/p>\n<p>  ftp = ftplib.FTP(addr_ftp)<br \/>  ftp.encoding = &quot;utf-8&quot;<br \/>  ftp.login(username, password)<br \/>  print(ftp.welcome)<br \/>  tlp = &#8221;'&lt;!DOCTYPE html&gt;<br \/>  &lt;html lang=&quot;en&quot;&gt;<br \/>  &lt;head&gt;<br \/>  &nbsp; &nbsp; &lt;meta charset=&quot;UTF-8&quot;&gt;<br \/>  &nbsp; &nbsp; &lt;meta http-equiv=&quot;Expires&quot; content=&quot;0&quot;&gt;<br \/>  &nbsp; &nbsp; &lt;meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;&gt;<br \/>  &nbsp; &nbsp; &lt;meta http-equiv=&quot;Cache-control&quot; content=&quot;no-cache&quot;&gt;<br \/>  &nbsp; &nbsp; &lt;meta http-equiv=&quot;Cache&quot; content=&quot;no-cache&quot;&gt;<br \/>  &nbsp; &nbsp; &lt;title&gt;TEST&lt;\/title&gt;<br \/>  &nbsp; &nbsp; &lt;style&gt;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;*{<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;color: #000000;<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;}<br \/>  &nbsp; &nbsp; &lt;\/style&gt;<br \/>  &lt;\/head&gt;<br \/>  &lt;body&gt;<br \/>  {{content}}<br \/>  &lt;\/body&gt;<br \/>  &lt;\/html&gt;&#8221;&#8217;<\/p>\n<p>  def upload_index(html):<br \/>  &nbsp; &nbsp; t = re.sub(r&quot;{{content}}&quot;, html, tlp)<br \/>  &nbsp; &nbsp; with open(&quot;temp&quot;, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;f.truncate()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;f.write(t)<br \/>  &nbsp; &nbsp; with open(&quot;temp&quot;, &quot;rb&quot;) as fp:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;ftp.storbinary(&quot;STOR index.html&quot;,fp, 1024)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(f&quot;{ftp.pwd()} \u4e0a\u4f20index.html\u6210\u529f\uff01&quot;)<\/p>\n<p>  def walk(newpath=&quot;.&quot;):<br \/>  &nbsp; &nbsp; ftp.cwd(newpath)<br \/>  &nbsp; &nbsp; dirs = []<br \/>  &nbsp; &nbsp; files = []<br \/>  &nbsp; &nbsp; curpath = ftp.pwd()<br \/>  &nbsp; &nbsp; if len(curpath.split(&quot;\/&quot;)) == 2:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;p = f'&lt;a href=&quot;\/index.html&quot;&gt;\u8fd4\u56de\u4e0a\u4e00\u7ea7&lt;\/a&gt;&amp;nbsp&amp;nbsp&lt;a href=&quot;\/index.html&quot;&gt;\u9996\u9875&lt;\/a&gt;&lt;br&gt;n&#8217;<br \/>  &nbsp; &nbsp; else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;l = curpath.split(&quot;\/&quot;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;sub = &#8216;\/&#8217;.join(l[:len(l)-1])<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;p = f'&lt;a href=&quot;{sub}\/index.html&quot;&gt;\u8fd4\u56de\u4e0a\u4e00\u7ea7&lt;\/a&gt;&amp;nbsp&amp;nbsp&lt;a href=&quot;\/index.html&quot;&gt;\u9996\u9875&lt;\/a&gt;&lt;br&gt;n&#8217;<\/p>\n<p>  &nbsp; &nbsp; for item in ftp.nlst():<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if item == &quot;index.html&quot;:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;ftp.delete(item)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;elif ftp.size(item):<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;files.append(item)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;dirs.append(item)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;walk(item)<\/p>\n<p>  &nbsp; &nbsp; for fi in files:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;path = curpath + fi if curpath == &quot;\/&quot; else curpath + &quot;\/&quot; + fi<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;p += f'&lt;a href=&quot;{path}&quot;&gt;{fi}&lt;\/a&gt;&lt;br&gt;n&#8217;<br \/>  &nbsp; &nbsp; <br \/>  &nbsp; &nbsp; for di in dirs:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;path = curpath + di if curpath == &quot;\/&quot; else curpath + &quot;\/&quot; + di<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;p += f'&lt;a href=&quot;{path}\/index.html&quot;&gt;{di}&lt;\/a&gt;&lt;br&gt;n&#8217;<\/p>\n<p>  &nbsp; &nbsp; upload_index(p)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;<br \/>  &nbsp; &nbsp; ftp.cwd(&quot;..&quot;)<\/p>\n<p>  if __name__ == &quot;__main__&quot;:<br \/>  &nbsp; &nbsp; try:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;walk()<br \/>  &nbsp; &nbsp; except Exception as e:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(e)<br \/>  &nbsp; &nbsp; finally:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;ftp.quit()<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;ftp.close()  \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>etc<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8c22\u8c22\u5927\u4f6c\u7684\u811a\u672c\uff0c\u9a6c\u4e0a\u8bd5\u8bd5\u53bb\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>chxin<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : \t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8fd8\u5b58\u6d3b\u5462&nbsp; &nbsp;zsbd:lol\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>yjsx86 \u5927\u4f6c\u6709\u8bdd\u8bf4 : u-&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\/18103"}],"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=18103"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/18103\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18103"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}