仅作演示用
from bs4 import BeautifulSoupimport urllib.requestwebfile = urllib.request.urlopen('http://www.baidu.com')webcontext = webfile.read().decode("UTF-8")soup = BeautifulSoup(webcontext,"html.parser")urlInfo = soup.findAll('div',id = 'u')print(urlInfo[0].next.text)print(urlInfo[0].next.get('href'))