Skip to content

Cav Scripts

Joshua Bell edited this page Nov 20, 2018 · 10 revisions

Google Apps Script Project URL

Site Tools

The site tools functions are built to grab certain information from from the 7th Cavalry Website after logging into the website. Currently the Google PropertiesService is used to fetch login information contained within the Script Properties (See table at end of page linked).

To call the Site Tools functions after importing the library use CavScripts.siteTools(). Also a new object must be created to utilize scripts.

getCookie()

This method gets the session cookie through the use of Google's urlFetchApp Service.

Input

Variable Name Type Description
user string 7Cav Forum username
pw string 7Cav Forum password

getPage will throw an error if the URL entered is not a proper 7cav.us URL.

Output

Variable Name Type Description
N/A string session cookie

getPage()

This method retrieves the raw HTML of a webpage that would require a login. Authentication for the forum is retrieved via the getCookie method documented above.

Input

Variable Name Type Description
URL string URL of a 7cav.us webpage

getThreads()

UNDER CONSTRUCTION

This method retrieves a list of threads present on a forum board.

Input

Variable Name Type Description
URL string 7Cav forum URL
pageOptions integer How the method will handle multiple pages [Default: 0] (see below for parameters) NOT IN USE... YET

pageOptions Parameters: (Will only use parameter 0 till feature is fixed)

  • 0 - Only first page
  • 1 - All pages
  • 2 - Only last page

getThreads will throw an error if the URL is not a proper 7cav.us forum URL (7cav.us/forums/).

Output

Primary output will be an array with each index being a object literal containing the following information about each post:

Variable Name Type Description
title string Thread title
id integer Thread id

parseThread()

This method grabs specific information from a thread

Examples:

siteTools.parseThread("https://7cav.us/threads/today-we-remember.41228/").threadAuthor;

//Will return "Parsons.B"
siteTools.parseThread("https://7cav.us/threads/today-we-remember.41228/").posts[0].contents;

//Will return raw HTML of the first post

Input

Variable Name Type Description
URL string URL of a 7cav.us thread
pageOptions integer How the method will handle multiple pages [Default: 0] (see below for parameters) NOT IN USE... YET

pageOptions Parameters: (Will only use parameter 0 till feature is fixed)

  • 0 - Only first page
  • 1 - All pages
  • 2 - Only last page

parseThread will throw an error if the URL is not a proper 7cav.us thread URL (7cav.us/threads/)

Output

Output will be parameters of parseThread (Ex parseThread().threadAuthor )

Key Type Description
title string Thread title
id integer Thread ID (see URL)
threadAuthor string Thread author (Ex: Smith.J)
parentForum string Name of forum thread is contained in
dateStart date JS date thread was started
posts array Array with information of every post. See below this table for further info.
dateUpdate date JS date of last post made to thread

posts Array

Each index in the array will be an object literal containing information about each post. See table below for information in each index

Key Type Description
author string Post author (Ex: Bell.K)
date date JS date post was created
contents string Raw HTML of the post contents
Clone this wiki locally