2017-10-23-(1)

# -*- coding utf-8 -*-
import requests
res =requests.get('http://www.qstheory.cn/2017-10/22/c_1121837612.htm')
res.encoding ='utf-8'
# print (res)
# print(res.text)
from bs4 import BeautifulSoup
html=res.text
soup=BeautifulSoup(html,'html.parser')
# print type(soup)
# print soup.text
Title=soup.select('h1')[0].text      #   提取标题
print Title
time=soup.select('span')[0].text  #  提取时间
print time
# mediaresource=soup.select('text')  # 提取来源(未成功)
# print mediaresource
content=soup.select('div.highlight')[0].text  #提取正文
print content

posted @ 2017-10-23 11:57  lh459384111  阅读(167)  评论(0编辑  收藏  举报