import matplotlib.pyplot as plt
from PIL import Image
from wordcloud import WordCloud , ImageColorGenerator
import numpy as np
import jieba
from imageio import imread
from urllib.request import urlopen
from urllib import request
from bs4 import BeautifulSoup
import socket
import time
from lxml import etree
import requests
def huitu():
text = open(r'C:\Users\admin\Desktop\text.txt',"r",encoding="utf-8").read()
cut_text=jieba.cut(text,cut_all=False)
result='/'.join(cut_text)
mask_of_result = imread(r'C:\Users\admin\Desktop\libai2.png')
wc = WordCloud(font_path=r"C:\Users\admin\Desktop\msyhl.ttc",background_color="white", max_words=2000, mask=mask_of_result)
wc.generate(result)
wc.to_file(r'C:\Users\admin\Desktop\libaiciyun2.png')
plt.imshow(wc, interpolation='bilinear')
plt.axis("off")
plt.figure()
plt.imshow(mask_of_result, cmap=plt.cm.gray, interpolation='bilinear')
plt.axis("off")
plt.show()
def find_libaisici(url_num=1):
url = "http://www.shicimingju.com/chaxun/zuozhe/1_"+str(url_num)+".html"
with requests.request('GET', url) as res:
content = res.text
html = etree.HTML(content)
orders = html.xpath('//*[@class="shici_content"]/text()')
print(orders)
if __name__ == "__main__":
huitu()