[Python] 网络爬虫

时间:2020-01-29 22:49:03   收藏:0   阅读:85

头元素信息:

<title>:文档标题,只有一个

<base>:默认链接

<link>:文档与外部资源关系,常用于链接样式表CSS

<style>:样式

<meta>:元数据,页面描述,关键字,文档作者等

<script>:客户端脚本,如JavaScript

 

获取网页:requests包

http请求方式:

get:90%以上

post

import requests
r = requests.get(url = https://www.baidu.com/s,params={wd:金正恩元帅},timeout=0.1)
#返回值
print(r)
print(type(r))
#网址
print(r.url)
#网页编码
print(r.encoding)
#网页源码
print(r.text)
#头域,返回字典
print(r.headers)

 

源码解析:BeautifulSoup包

 

分析文档树

子节点:.content

 

原文:https://www.cnblogs.com/cxc1357/p/10584752.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!