Giter Site home page Giter Site logo

spider.java's Introduction

用JavaURL编程爬取并分析网页敏感词

实验内容

  1. 编写界面,输入一个网址,能够爬取该网址上所有的HTML源代码。
  2. 对网址中的文本进行提取。
  3. 建立敏感词库,用文本文件保存。
  4. 将该网址所对应的文本中的敏感词提取并高亮显示。
  5. 编写文本文件,可以存入多个网址;程序可爬取这些网址中的文本内容,将敏感词记录存入另一个文件,格式自定。
  6. 编写一个主界面,整合上述功能。

业务分析

(一)总体背景

由于互联网的普及和信息爆炸,敏感词检测的需求十分重要,以下是敏感词检测的重要性: - 对于社交媒体平台:敏感词检测可以帮助社交媒体平台监控和管理用户生成内容,防止传播不良信息、恶意攻击、仇恨言论等。 - 对于在线论坛和评论系统:敏感词检测可以过滤包含敏感词汇的评论和帖子,维护良好的讨论环境,防止网络欺凌和辱骂行为。 - 对于新闻媒体和出版业:敏感词检测可以帮助新闻机构和出版商筛查文章和内容,确保发布的信息符合相关法规和道德标准。

所以本实验旨在开发一个用JavaURL编程实现的网页爬取和敏感词分析程序,以解决这一问题。

(二)业务分析

1.爬取框架选择:

  • 创建一个URL对象表示要爬取的网页地址,然后打开一个URLConnection连接对象进行连接。接着使用BufferedReader从连接的输入流中读取HTML源代码。

2.文本提取及特殊处理:

  • 引入第三方库Jsoup库,Safelist白名单和正则表达式等技术来处理文本内容,通过去除HTML中的实体编码等乱码现象,来获得处理后的纯文本内容。

3.敏感词库建立:

  • 敏感词库拥有三个等级的敏感词,分别是高风险词,中风险词和低风险词。
  • 用户分别在不同等级的风险等级下自定义敏感词,每一行存储一个敏感词。

4.敏感词标记:

  • 处理后的纯文本内容将显示在页面上,接着通过Highlighter对象对文本内容进行敏感词的检索并进行根据不同风险等级进行不同颜色的标记。
  • 红色标记代表高风险词,黄色标记代表中风险词,灰色代表低风险词。

5.图形化设计:

  • 由于有单网址和多个网址的爬取,所以分别为这两个爬取模式设置不同的窗口。

spider.java's People

Contributors

ljqcore avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.