python学习笔记(二) BeautifulSoup

来源:互联网 发布:描绘网络的 电影 编辑:程序博客网 时间:2024/05/16 17:58
在python3.x中使用BeautifulSoup稍有不同,请参照下面
import urllib.requestfrom bs4 import BeautifulSoupurl = input("Enter-")html = urllib.request.urlopen(url)soup = BeautifulSoup(html,'html.parser')tags = soup('a')
#soup相当于建立一个dict()
for tag in tags:    print(tag.get('href',None))
0 0
原创粉丝点击