首页 > 编程语言 > 详细

Python BeautifulSoup的使用

时间:2017-07-24 23:01:46      阅读:176      评论:0      收藏:0      [点我收藏+]

2017-07-24 22:39:14 

Python3 中的beautifulsoup引入的包是bs4

import requests
from bs4 import *

r = requests.get(‘http://jwc.seu.edu.cn/‘)

soup = BeautifulSoup(r.text,‘html.parser‘)

#prettify()函数可以将html以易读的形式展现出来
print(soup.prettify())

#find_all(tag) 返回所有的tag,可以使用字典的索引方式进行查找到你需要的东西
for k in soup.find_all(‘link‘):
    print(k[‘href‘])

 

Python BeautifulSoup的使用

原文:http://www.cnblogs.com/TIMHY/p/7231611.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!