Skip to content

A collection of articles about cult filmmaker and King of Filth, John Waters

Notifications You must be signed in to change notification settings

Meekb/FilthyAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FilthyAPI

A collection of articles about cult filmmaker and King of Filth, John Waters

Overview

Using Node.js and Express, this basic API uses the npm package cheerio to scrape websites for <a> tags that contain "John Waters":

Instructions

  1. Clone this project
  2. cd into the project from your terminal
  3. npm i to install dependencies
  4. npm start to start local server
  5. Open browser to localhost:8000
//Here, we run through our articles array and forEach site, we establish a cheerio variable and scrape
// the site for a couple of variations of "John Waters" contained within the anchor tags 
articles.forEach(site => {
  axios.get(site.address)
    .then((response) => {
      const html = response.data
      const $ = cheerio.load(html)

        // looking for anchor tags that contain "John Waters" within emphasis tags
      $('a:contains("<em>John Waters</em>")', html).each(function() {
        const title = $(this).text().replace(/[^0-9a-z-A-Z ]/g, "").replace(/ +/, " ")
        const url = $(this).attr('href')
	// if we find tags that are not advertisements
        if (title !== "" && title !== "_" && title !== 'acontains' && !title.includes('discount') && !title.includes('Accessories') && !title.includes('mediamax-width') && url) {
	// push them into a madia array with defined key/values
          media.push({
            title,
            url: site.base ? site.base + url : url,
            source: site.name
          })
        }
      })
      
       // looking for anchor tags that contain "John Waters"
      $('a:contains("John Waters")', html).each(function() {
        const title = $(this).text().replace(/[^0-9a-z-A-Z ]/g, "").replace(/ +/, " ")
        const url = $(this).attr('href')
	// if we find tags that are not advertisements
        if (title !== "" && title !== "_" && title !== 'acontains' && !title.includes('discount') && url && title.length < 300 && url.length < 300) {
	// push them into a madia array with defined key/values
          media.push({
            title,
            url: site.base ? site.base + url : url,
            source: site.name
          })
        }
      })
    })
})

Endpoint Code Snippets

  • GET all articles
var axios = require("axios").default;

var options = {
  method: 'GET',
  url: 'https://filthyapi.p.rapidapi.com/articles',
  headers: {
    'x-rapidapi-host': 'filthyapi.p.rapidapi.com',
    'x-rapidapi-key': '07c49e7131msh1df335cef06dbe8p1c0393jsn50aa8ba72cbf'
  }
};

axios.request(options).then(function (response) {
	console.log(response.data);
}).catch(function (error) {
	console.error(error);
});
  • GET article by specific source
var axios = require("axios").default;

var options = {
  method: 'GET',
  url: 'https://filthyapi.p.rapidapi.com/articles/theadvocate',
  headers: {
    'x-rapidapi-host': 'filthyapi.p.rapidapi.com',
    'x-rapidapi-key': '07c49e7131msh1df335cef06dbe8p1c0393jsn50aa8ba72cbf'
  }
};

axios.request(options).then(function (response) {
	console.log(response.data);
}).catch(function (error) {
	console.error(error);
});

Project Deployed on Heroku

King of Filth API

API

Connect on RapidAPI

Tech Stack

Node.js Express npm Axios Heroku

Contributors

Built with the help of developer GODDESS Ania Kubow

Beth Meeker GH
Beth Meeker avatar

About

A collection of articles about cult filmmaker and King of Filth, John Waters

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published