2017-10-23-2

# -*- coding utf-8 -*-
import requests
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import jieba
import sys
print sys.getdefaultencoding()
reload(sys)
sys.setdefaultencoding('UTF8')
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
op=open('shijiuda.txt','w')
op.write(soup.select('div.highlight')[0].text)
op.close()
len_content=len(content)
print len(content)
print len(html)

posted @ 2017-10-23 18:03  lh459384111  阅读(134)  评论(0编辑  收藏  举报