# coding:utf-8
import requests
# 请求地址
# url = "https://www.qlchat.com"
url = "https://www.baidu.com"
headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chro'
                      'me/53.0.2785.104 Safari/537.36 Core/1.53.2372.400 QQBrowser/9.5.10548.400'
}
r = requests.get(url,headers=headers,verify=False)
print(r.status_code)
print(r.text)

  

 

然后修改:

# coding:utf-8
import requests
# 请求地址
# url = "https://www.qlchat.com"
url = "https://www.baidu.com/xxx"
headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chro'
                      'me/53.0.2785.104 Safari/537.36 Core/1.53.2372.400 QQBrowser/9.5.10548.400'
}
r = requests.get(url,headers=headers,verify=False)
print(r.status_code)
print(r.text)


------返回------
404
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /xxx was not found on this server.</p>
</body></html>

  

相关文章:

  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-11-12
  • 2021-12-12
  • 2022-02-20
  • 2021-10-04
猜你喜欢
  • 2021-07-22
  • 2022-02-22
  • 2021-10-04
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-10-02
相关资源
相似解决方案