import requests from bs4 import BeautifulSoup import re import time import jieba import wordcloud import matplotlib.pyplot as plt import pandas as pd from pandas import ExcelWriter from collections import Counter headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0', } keywords = [ 'AI', '人工智能', '机器学习', '深度学习', '神经网络', '自动化', '算法', '数据科学' '自然语言处理', '计算机视觉', '人工智能技术', 'AI技术', 'AI应用', 'AI模型', '大数据', '预测分析', '机器视觉', '自动驾驶', '智能推荐', '计算机科学', '人工智能应用', '数据分析','智能化', '情感计算','ai' ] def sort(txt, keywords): comment_counter = Counter() for line in txt: line.strip() if any(word in keywords for word in jieba.cut(line)): comment_counter[line] += 1 return comment_counter