使用爬虫中http与https的区别
2018-03-14 16:17
561 查看
HTTPS全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。(这是百度百科上的解释)
下面我们看在爬虫中二者的区别,下面通过两个程序来说明:
def search1(keyboard):
url="http://www.baidu.com/s?wd="+keyboard
con=requests.get(url).text
return con
search1('王者荣耀')
输出结果:'<!DOCTYPE html>\n<!--STATUS OK-->\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\n\n\n<html>\n\t<head>\n\t\t\n\t\t<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n\t\t<meta http-equiv="content-type" content="text/html;charset=utf-8">\n\t\t<meta content="always" name="referrer">\n <meta name="theme-color" content="#2932e1">\n <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />\n <link rel="icon" sizes="any" mask href="//www.baidu.com/img/baidu_85beaf5496f291521eb75ba38eacbd87.svg">\n <link rel="search" type="application/opensearchdescription+xml" href="/content-search.xml" title="百度搜索" />\n\t\t\n\t\t\n<title>王者荣耀_百度搜索</title>\n\n\t\t\n\n\t\t\n<style data-for="result" type="text/css" id="css_newi_result">body{color:#333;background:#fff;padding:6px 0 0;margin:0;position:relative;min-width:900px}\nbody,th,td,.p1,.p2{font-family:arial}\np,form,ol,ul,li,dl,dt,dd,h3{margin:0;padding:0;list-style:none}\ninput{padding-top:0;padding-bottom:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}\ntable,img{border:0}\ntd.................'
def search2(keyboard):
url="https://www.baidu.com/s?wd="+keyboard
con=requests.get(url).text
return con
search2('王者荣耀')
输出结果:'<html>\r\n<head>\r\n\t<script>\r\n\t\tlocation.replace(location.href.replace("https://","http://"));\r\n\t</script>\r\n</head>\r\n<body>\r\n\t<noscript><meta http-equiv="refresh" content="0;url=http://www.baidu.com/"></noscript>\r\n</body>\r\n</html>'
HTTPS全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。(这是百度百科上的解释)
下面我们看在爬虫中二者的区别,下面通过两个程序来说明:
def search1(keyboard):
url="http://www.baidu.com/s?wd="+keyboard
con=requests.get(url).text
return con
search1('王者荣耀')
输出结果:'<!DOCTYPE html>\n<!--STATUS OK-->\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\t\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\n\n\n<html>\n\t<head>\n\t\t\n\t\t<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n\t\t<meta http-equiv="content-type" content="text/html;charset=utf-8">\n\t\t<meta content="always" name="referrer">\n <meta name="theme-color" content="#2932e1">\n <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />\n <link rel="icon" sizes="any" mask href="//www.baidu.com/img/baidu_85beaf5496f291521eb75ba38eacbd87.svg">\n <link rel="search" type="application/opensearchdescription+xml" href="/content-search.xml" title="百度搜索" />\n\t\t\n\t\t\n<title>王者荣耀_百度搜索</title>\n\n\t\t\n\n\t\t\n<style data-for="result" type="text/css" id="css_newi_result">body{color:#333;background:#fff;padding:6px 0 0;margin:0;position:relative;min-width:900px}\nbody,th,td,.p1,.p2{font-family:arial}\np,form,ol,ul,li,dl,dt,dd,h3{margin:0;padding:0;list-style:none}\ninput{padding-top:0;padding-bottom:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}\ntable,img{border:0}\ntd.................'
def search2(keyboard):
url="https://www.baidu.com/s?wd="+keyboard
con=requests.get(url).text
return con
search2('王者荣耀')
输出结果:'<html>\r\n<head>\r\n\t<script>\r\n\t\tlocation.replace(location.href.replace("https://","http://"));\r\n\t</script>\r\n</head>\r\n<body>\r\n\t<noscript><meta http-equiv="refresh" content="0;url=http://www.baidu.com/"></noscript>\r\n</body>\r\n</html>'
相关文章推荐
- HTTP和HTTPS有什么区别? 什么是SSL证书?使用ssl证书优势?
- HTTP和HTTPS有什么区别? 什么是SSL证书?使用ssl证书优势?
- HTTP和HTTPS有什么区别? 什么是SSL证书?使用ssl证书优势?
- Socket http和https的使用区别
- HTTP和HTTPS有什么区别? 什么是SSL证书?使用ssl证书优势?
- HTTPS和HTTP的区别(转载)
- https协议和Http协议的区别
- C#、VB.NET使用HttpWebRequest访问https地址(SSL)的实现
- HTTP协议中POST、GET、HEAD的区别是什么?分别在什么情况下使用?(
- HTTPS和HTTP的区别
- HTTPS和HTTP的区别
- HTTP和HTTPS协议的区别
- HTTPS和HTTP的区别
- 读书笔记:HTTPS和HTTP的区别
- http与https的区别
- http 和https的区别
- dotnet 使用HttpWebRequest向Https Post数据时,需要证书确认的解决方法
- 使用 gSOAP 通过 HTTP 和 HTTPS 调用由 WSAD 创建的 J2EE Web 服务
- HTTPS和HTTP的区别
- fw:http 与 https 区别