import requests
# import jieba
# import pandas
# import matplotlib.pyplot as plt
# from wordcloud import WordCloud, ImageColorGenerator
from bs4 import BeautifulSoup
# def jieba_cut(sentence):
# # seg = jieba.cut(sentence)
# segList = []
# for i in seg:
# segList.append((i))
# return segList
if __name__ == '__main__':
str = ''
url = 'http://comment.bilibili.com/36773399.xml'
page = requests.get(url)
page.encoding = 'utf-8'
soup = BeautifulSoup(page.text, "html.parser")
content = soup.find_all('d')
for i in content:
# str = str + i.text
print(i.text)
# with open('bilibili.txt', 'w', encoding='utf-8') as f:
# f.write(str)
#
# dict = {}
# with open('bilibili.txt', 'r', encoding='utf-8') as f:
# words = jieba_cut(f.read())
# wordslist = set(words)
# for word in wordslist:
# dict[word] = words.count(word)
# mask = plt.imread(r'H:\129\wallhaven-627476.jpg')
# text = ' '.join(words)
# wc = WordCloud(
# width=1000,
# height=800,
# margin=2,
# background_color='white', # 設置背景顏色
# font_path='C:\Windows\Fonts\STZHONGS.TTF', # 若是有中文的話,這句代碼必須添加,不然會出現方框,不出現漢字
# max_words=1000, # 設置最大現實的字數
# max_font_size=400, # 設置字體最大值
# random_state=50, # 設置有多少種隨機生成狀態,即有多少種配色方案
# mask=mask,
# )
# mycloud = wc.generate(text)
# image_colors = ImageColorGenerator(mask)
#
# wc.recolor(color_func=image_colors)
# wc.to_file('cloudword.jpg')