demo_requests_get_url.py:
import requests #the required first parameter of the 'get' method is the 'url': x = requests.get('https://www.begtut.com/try/python/demopage.html') #print the response text (the content of the requested file): print(x.text)
➜ begtut>python demo_requests_get_url.py
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<title>新手教程(begtut.com)</title>
<body>
<h1>这是一个测试页面</h1>
</body>
</html>