Python爬链接

# -*- coding: utf-8 -*-
"""
Created on Wed Jan 11 17:21:54 2017

@author: PE-Monitor
"""
from urllib2 import urlopen
from bs4 import BeautifulSoup

html =urlopen("https://hao.360.cn/")
bsobj =BeautifulSoup(html)
nameList =bsobj.findAll('a')
for name in nameList:
if 'href' in name.attrs:
print name.string,':',name.attrs['href']

  

posted @ 2017-01-11 17:57  体育.委员  阅读(232)  评论(0编辑  收藏  举报