第1关:获取新闻url
import requests
import re
def geturls():
# ********** Begin ********** #
url='http://www.qstheory.cn/dukan/qs/2014/2019-01/01/c_1123924172.htm'
headers={
'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36'
}
response=requests.get(url=url,headers=headers)
# print(response.encoding)
response = response.text
response = response.encode("ISO-8859-1")
# decode解码,将unicode解码成utf-8
response = response.decode("utf-8")
with open('./求是网.html','w',encoding='utf-8') as file:
file.write(response)
# <