擅长:python、mysql、java
<p>一种方法是使用pythons请求模块。您可以通过执行pip安装请求来获得它(如果不使用virtualenv,则可能必须使用sudo)。在</p>
<pre><code>import requests
res = requests.get('http://www.york.ac.uk/teaching/cws/wws/webpage1.html')
if res.status_code == 200: # check that the request went through
# print the entire html, should maintain internal newlines so that when it print to screen it isn't on a single line
print(res.content)
#if you want to split the html into lines, use the split command like below
#lines = res.content.split('\n')
#print(lines)
</code></pre>