Error accessing python requests URL

import requests
from bs4 import BeautifulSoup
import re
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3521.2 Safari/537.36"
headers = {" User-Agent":user_agent}
url =" http://bxjg.bis.gov.cn//web/s."

session = requests.session ()
session.headers = headers
requests.adapters.DEFAULT_RETRIES = 50
session.keep_alive = False
r = session.get (url)

there is an error in the execution of the above code: it doesn"t work to look up a lot of methods on the Internet, ask for advice

clipboard.png

Nov.12,2021

cannot find bxjg.bis.gov.cn 's server DNS address.

website logged out ~


url = 'http://bxjg.bis.gov.cn//web/s.'
there is a problem in this line web is preceded by / /
, which will cause the parsing error of urllib3 http://bxjg.bis.gov.cn// = = shecme (protocol)

your hostname = = web/site0/tab. so just remove a /


there's something wrong with your url. I changed it to this. No, no, no. The website has been changed to Baidu.
import requests
from bs4 import BeautifulSoup
import re

headers = {

'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3521.2 Safari/537.36'

}

url =' https://www.baidu.com'

session = requests.session ()

requests.adapters.DEFAULT_RETRIES = 50

session.keep_alive = False

r = session.get (url, headers=headers)
print (r)

Menu