仅作演示用
from bs4 import BeautifulSoup
import urllib.request webfile = 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[].next.text)
print(urlInfo[].next.get('href'))