Git Product home page Git Product logo

wikipedia-query's Introduction

Wikipedia Query

A simple command line tool that provides basic information (provided by Wikipedia) on a user supplied topic.

Running

You can use sbt to run the program. It will automatically install the dependencies.

There are two ways to make queries:

  • Enter sbt run and you will be prompted for a topic.
  • Pass a command line argument into the program using something of the form sbt "run <topic>"

About

The program is straight forward. It either reads the topic from the command line or prompts the user if there is none. It then attempts to connect to the relevant Wikipedia page. If it fails to connect or encounters any other error in the process, it will return "Not found.". Otherwise it will parse the response to get the first paragraph from Wikipedia. We make use of the fact that the main content of Wikipedia articles are wrapped in a div with the id 'mw-content-text'.

This project makes use of jsoup, an html parsing library. It is a well documented, straight forward library that addresses the tasks I needed (getting the contents of a webpage and pulling out the first paragraph). This project also makes use of Scala's Try library to handle any exception we might get when connecting to a page (such as a 404, 503, etc).

wikipedia-query's People

Contributors

bgapinski avatar

Watchers

 avatar James Cloos 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.