一、要求:
1、完成论文的题目、摘要、关键词、原文链接四项内容爬取;
2、存储到本地数据库中;
3、按照题目、关键词分类统计得到最热的十个领域方向;
4、热词越多,在热词云中显示的就越大,还要将热词与文章链接,点击热词云中的热词可以找到与之对应的文章题目;
二、效果:
三、设计思路:
1、(队友杨晓)使用python爬取、存取数据:
from lxml import etree from pymysql import connect from jieba.analyse import * import requests class CVPR: # 保存数据 def saveContent_list(self,title,zhaiyao,guanjian,lianjie): # 打开数据库连接(ip/数据库用户名/登录密码/数据库名) con = connect("localhost", "root", "a3685371", "pachong") # 使用 cursor() 方法创建一个游标对象 cursor cursors = con.cursor() # 使用 execute() 方法执行 SQL 查询 返回的是你影响的行数 row = cursors.execute("insert into CVPR values(%s,%s,%s,%s)", (title,zhaiyao,guanjian,lianjie)) # 使用 fetchone() 方法获取数据. con.commit() # 关闭数据库连接(别忘了) con.close() headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" } url = "http://openaccess.thecvf.com/CVPR2019.py" proxies = { "http": "http://211.147.226.4", "https": "http://122.200.90.12", } cvpr = CVPR() response = requests.get(url,headers=headers) html_str = etree.HTML(response.content.decode()) #获得标题 hrefs = html_str.xpath("//div[@id='content']/dl/dt/a/@href") for href in hrefs: href = "http://openaccess.thecvf.com/{0}".format(href) response2 = requests.get(href,headers=headers) html_str = etree.HTML(response2.content.decode()) lunwens = {} title = html_str.xpath("//div[@id='content']/dl/dd//div[@id='papertitle']/text()") lianjie = html_str.xpath("//div[@id='content']/dl/dd//a/@href") zhaiyao = html_str.xpath("//div[@id='content']/dl/dd//div[@id='abstract']/text()") for keyword, weight in extract_tags(zhaiyao[0].strip(), topK=5, withWeight=True): try: cvpr.saveContent_list(title,zhaiyao,keyword,lianjie) print("存入成功") except: print("存入失败")