#coding:utf-8 #设置文本格式
import requests # 引入request库
from bs4 import BeautifulSoup
url = 'http://news.qq.com'
wbdata = requests.get(url).text #request.get方法获取url
soup = BeautifulSoup(wbdata,'lxml')
news_titles = soup.select('div > div > em > a') 获取select 的路径
for n in news_titles: # news_titles 循环
title = n.get_text()
link = n.get('href')
data = {
'标题':title,
'链接':link,
}
print(data) #数据打印出来