import requests import re import numpy """ baidu.com """ url = "https://www.baidu.com/" headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36" } res = requests.get(url=url, headers=headers) # print(res.content.decode()) print(res.headers) # response headers print(res.encoding) # encoding print(res.url) # url print(res.cookies) # cookie print(res.request) # request object print(res.status_code) # status print(res.reason) # OK print(res.raw) """ output: PS E:1documentsPyTorch> & C:/Users/1/AppData/Local/Programs/Python/Python38/python.exe e:/1/documents/PyTorch/爬虫/crawlering_basic/basic01.py {'Bdpagetype': '1', 'Bdqid': '0xdda5a3cc00029c72', 'Cache-Control': 'private', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Content-Type': 'text/html;charset=utf-8', 'Date': 'Sat, 22 Jan 2022 12:50:08 GMT', 'Expires': 'Sat, 22 Jan 2022 12:50:06 GMT', 'P3p': 'CP=" OTI DSP COR IVA OUR IND COM ", CP=" OTI DSP COR IVA OUR IND COM "', 'Server': 'BWS/1.1', 'Set-cookie': 'BAIDUID=E5EC85CADC16EF8D330516F968D186DC:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com, BIDUPSID=E5EC85CADC16EF8D330516F968D186DC; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com, PSTM=1642855808; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com, BAIDUID=E5EC85CADC16EF8DD71B27FC36E9A130:FG=1; max-age=31536000; expires=Sun, 22-Jan-23 12:50:08 GMT; domain=.baidu.com; path=/; version=1; comment=bd, BDSVRTM=0; path=/, BD_HOME=1; path=/, H_PS_PSSID=35411_35104_31253_35733_35488_35776_34584_35490_35700_34812_35796_35323_26350_35751_35746; path=/; domain=.baidu.com, BAIDUID_BFESS=E5EC85CADC16EF8D330516F968D186DC:FG=1; Path=/; Domain=baidu.com; Expires=Thu, 31 Dec 2037 23:55:55 GMT; Max-Age=2147483647; Secure; SameSite=None', 'Strict-Transport-Security': 'max-age=172800', 'Traceid': '1642855808048997633015971351750108159090', 'X-frame-Options': 'sameorigin', 'X-Ua-Compatible': 'IE=Edge,chrome=1', 'Transfer-Encoding': 'chunked'} utf-8 https://www.baidu.com/, , , , , , ]> 200 OK PS E:1documentsPyTorch> """
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)