擅长:python、mysql、java
<p>一个简单的循环应该可以工作。我已经删除了第一个标记,因为它可能是合理的信息。只需使用第一个链接的代码更改<code>WRITE_YOUR_FIRST_TOKEN_HERE</code>字符串</p>
<pre><code>from urllib import request
def get_chunk(chunk, url='https://www.uchicago.computer/api.php?file='):
with request.urlopen(url + chunk) as f:
return f.read().decode('UTF-8').strip()
if __name__ == '__main__':
chunk = 'WRITE_YOUR_FIRST_TOKEN_HERE'
while chunk[-3:] != "END":
chunk = get_chunk(chunk[-64:])
print(chunk)
# Chunk is a string, do whatever you want with it,
# like chunk.splitlines() to get a list of the lines
</code></pre>
<p><code>read</code>获取字节流,<code>decode</code>将其转换为字符串,<code>strip</code>移除前导和尾随空格(如<code>\n</code>),这样它就不会与最后64个字符混淆(如果您获取最后64个字符,但其中一个是<code>\n</code>,那么您将只获得63个字符的令牌)</p>