Python BeautifulSoup的使用

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'])

 

posted @ 2017-07-24 22:40  hyserendipity  阅读(245)  评论(0编辑  收藏  举报