完成作业3
This commit is contained in:
11
homework02.py
Normal file
11
homework02.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import requests
|
||||||
|
url = 'https://example.com'
|
||||||
|
params = {'key': 'value'}# 查询参数
|
||||||
|
# 发送GET请求并带上查询参数
|
||||||
|
response = requests.get(url, params=params)
|
||||||
|
#检查请求是否成功
|
||||||
|
if response.status_code == 200:
|
||||||
|
html_content = response.text
|
||||||
|
print("请求成功,获取到HTML内容")
|
||||||
|
else:
|
||||||
|
print(f"请求失败,状态码:{response.status_code}")
|
||||||
Reference in New Issue
Block a user