import re,requests
def parse_response(url):
header = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/63.0.3239.132 Safari/537.36 '
}
response = requests.get(url, headers=header, timeout=2)
response.encoding = 'UTF-8'
html = response.text
pattern = re.compile('<title>(.*?)</title>', re.S)
items = re.findall(pattern, html)
print(items[0])
return items
if __name__ == "__main__":
url=input('输入网址:')
parse_response(url)