Skip to content

juliustao/news-balance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News Balance

Environment

This code is tested with Python 3.6.9 on Ubuntu 18.04 in the Chromium browser.

  • Any recent version of Python 3 should work.
  • Although not tested on Windows or Mac, there is no OS-specific code. I expect Mac to work out-of-the-box, but Windows will need some adjustments.
  • Google Chrome should work. To use another browser, download its webdriver in the setup below and change run.py so driver uses the correct browser.

Getting Started

  1. Check if you have Python 3 by running python3 --version. If not found, install Python 3 from here.

  2. I highly recommend that you create a Python 3 virtual environment:

    python3 -m venv PATH_TO_VENV
    

    Activate the environment:

    source PATH_TO_VENV/bin/activate
    

    To activate in Windows:

    PATH_TO_VENV\Scripts\activate.bat
    
  3. Install pip dependencies:

    pip install -r requirements.txt
    
  4. Install the Selenium webdriver:

    See here for links to webdrivers for Selenium-compatible browsers. Place the unzipped folder under this repository, and remember to specify the driver path later.

    Windows users may need the details underneath the section from the above link.

  5. Sanity-check the backend:

    Copy the URL of some news article from Fox or Vox and run

    python3 test.py --url THAT_URL
    
  6. Open the Selenium browser:

    Before running python3 run.py, check that the default arguments are satisfactory. If not, specify them accordingly.

    A Selenium browser should appear. If you begin reading any partisan news article, you'll be interrupted by a new tab with similar content but contrasting viewpoint.

    The original intent is to show centrist articles, but I added an option to show articles from opposing viewpoints. Be warned though, as the newly shown articles are partisan and will spawn opposing articles themselves! That might just be intended to encourage centrism though 😉

Details

The core of this repository is its backend, which checks a given article's political bias and recommends an article of similar content from a more central viewpoint. We scrape the news site AllSides by querying the given article's title in its search engine and filtering for articles that are centrist and most relevant.

The frontend is what I had the most trouble with. Ideally, we could detect when a new webpage is loaded and send its URL to the backend, which is surprisingly difficult to do from native Python. Selenium works fine, but I'd love to see a native-browser solution!

About

As partisan divisions grow, it's easier than ever to get stuck in a bubble of biased media. News Balance checks the political leaning of your current article and recommends you one of similar content but different viewpoint.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages