码迷,mamicode.com
首页 > 编程语言 > 详细

Python BeautifulSoup的使用

时间:2017-07-24 23:35:26      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:span   for   bs4   import   html   字典   函数   pytho   ref   

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的使用

标签:span   for   bs4   import   html   字典   函数   pytho   ref   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!