Commit 45f90bf3 authored by William Hensel's avatar William Hensel

Added readme

parent d2cc64cf
......@@ -51,8 +51,8 @@
</style>
<body class="container">
<span class="holder">&#9711;</span>
<span class=mainnum>10</span>
<span class="holder"><!--&#9711;--></span>
<span class=mainnum>15</span>
<div class="textblock">
<p>Remaining Flex Dollars:</p>
<p>Wolf Parent Passes left:</p>
......@@ -64,9 +64,9 @@
</div>
</div>
<div class="letblock">
<p>$100.60</p>
<p>$75.30</p>
<div id="bottom">
<p>45</p>
<p>7</p>
</div>
</div>
......
......@@ -11,54 +11,58 @@
int main(){
StudentData studentData;
int totalCredits;
int totalParentPasses;
double totalFlexDollars;
cout << "Running" << endl;
// Get information from HTML recieved from the cafeteria website and create a studentData object with the information
try{
/***CHANGE CAFETERIA HTML FILE NAME HERE***/
vector<string> hLines = readHTMLFromFile("Sample.html");
while(true){
StudentData studentData;
int totalCredits;
int totalParentPasses;
double totalFlexDollars;
string mealPlanType = getPlanType(hLines);
// Get information from HTML recieved from the cafeteria website and create a studentData object with the information
try{
/***CHANGE CAFETERIA HTML FILE NAME HERE***/
vector<string> hLines = readHTMLFromFile("Sample.html");
string mealPlanType = getPlanType(hLines);
int creditElementLocation = findCreditElement(hLines, mealPlanType);
int parentPassLocation = findParentPassElement(hLines, mealPlanType);
int flexElementLocation = findFlexElement(hLines, mealPlanType);
totalCredits = extractCredit(hLines.at(creditElementLocation));
totalParentPasses = extractCredit(hLines.at(parentPassLocation));
totalFlexDollars = extractFlex(hLines.at(flexElementLocation));
studentData = StudentData(totalCredits, totalParentPasses, totalFlexDollars);
}
catch(runtime_error &excpt){
cout << excpt.what() << endl;
}
int creditElementLocation = findCreditElement(hLines, mealPlanType);
int parentPassLocation = findParentPassElement(hLines, mealPlanType);
int flexElementLocation = findFlexElement(hLines, mealPlanType);
// DEBUG CODE
// cout << "Total credits: " << studentData.getCredits() << endl;
// cout << "Total Wolf Parent Passes: " << studentData.getWolfParentPasses() << endl;
// cout << "Total Flex Dollars: " << fixed << setprecision(2) << studentData.getFlexDollars() << endl;
totalCredits = extractCredit(hLines.at(creditElementLocation));
totalParentPasses = extractCredit(hLines.at(parentPassLocation));
totalFlexDollars = extractFlex(hLines.at(flexElementLocation));
// Insert data into a template file and write the information to landing page HTML file
try{
/***CHANGE TEMPLATE FILE NAME HERE***/
vector<string> trackerLines = readFile("Template.html");
insertData(trackerLines, totalCredits, totalParentPasses, totalFlexDollars);
/***CHANGE LANDING PAGE FILE NAME HERE***/
writeFile(trackerLines, "CreditTracker.html");
}
catch(runtime_error &excpt){
cout << excpt.what() << endl;
}
studentData = StudentData(totalCredits, totalParentPasses, totalFlexDollars);
this_thread::sleep_for (chrono::seconds(5)); // Sleep for 10 seconds
}
catch(runtime_error &excpt){
cout << excpt.what() << endl;
}
// DEBUG CODE
cout << "Total credits: " << studentData.getCredits() << endl;
cout << "Total Wolf Parent Passes: " << studentData.getWolfParentPasses() << endl;
cout << "Total Flex Dollars: " << fixed << setprecision(2) << studentData.getFlexDollars() << endl;
// Insert data into a template file and write the information to landing page HTML file
try{
/***CHANGE TEMPLATE FILE NAME HERE***/
vector<string> trackerLines = readFile("Template.html");
insertData(trackerLines, totalCredits, totalParentPasses, totalFlexDollars);
/***CHANGE LANDING PAGE FILE NAME HERE***/
writeFile(trackerLines, "CreditTracker.html");
}
catch(runtime_error &excpt){
cout << excpt.what() << endl;
}
this_thread::sleep_for (chrono::seconds(10)); // Sleep for 10 seconds
return 0;
}
# README
## How to use this program
* This program was written with organization in mind. The files crucial to the
core functionality are located in their own folders.
* To run, open a terminal in the ~/cptr142_group_project directory.
* Enter the following command in the terminal to run the program
```
g++ -std=c++11 HTMLInserting/InsertingFunctions.cpp HTMLParsing/ParsingFunctions.cpp StudentData/StudentData.cpp Main/main.cpp && ./a.out
```
* Press CTRL-C to stop the program. It will run infinitly every 5 seconds if you don't. It's designed to be constantly updating the webpage.
......@@ -5,13 +5,19 @@
| Class Data |
|--------------------------------------------------------------|
|Public: |
| + void getName() // accessor for user name |
| + void getMealCount() // accessor for mealCount |
| + Data(string name) // constructor, takes name |
| + StudentData() |
| + StudentData(int credit, int parent, double flex) |
| + void setCredits(int credit) |
| + void setWolfParentPasses(int passes) |
| + void setFlexDollars(double flex) |
| + int getCredits() |
| + int getWolfParentPasses() |
| + double getFlexDollars() |
|--------------------------------------------------------------|
|Private: |
| - string name |
| - int mealCount |
| - int credits |
| - int wolfParentPasses |
| - double flexDollars |
|--------------------------------------------------------------|
# User Interface Design
......
......@@ -164,7 +164,7 @@ function showDetails(id){
</td>
<td nowrap="">Wolves-Parents Pass</td>
<td nowrap="">800025877851</td>
<td nowrap=""><div align="right"> 45</div></td>
<td nowrap=""><div align="right"> 7</div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td nowrap="">
......@@ -172,7 +172,7 @@ function showDetails(id){
</td>
<td nowrap="">Gold Flex 12</td>
<td nowrap="">800025877855</td>
<td nowrap=""><div align="right"> 10</div></td>
<td nowrap=""><div align="right"> 15</div></td>
</tr>
<tr bgcolor="#CCCCCC">
<td nowrap="">
......@@ -180,7 +180,7 @@ function showDetails(id){
</td>
<td nowrap="">Gold Flex 110</td>
<td nowrap="">800025877853</td>
<td nowrap=""><div align="right"> $ 100.60</div></td>
<td nowrap=""><div align="right"> $ 75.30</div></td>
</tr>
<!-- American Express Status -->
......
......@@ -51,7 +51,7 @@
</style>
<body class="container">
<span class="holder">&#9711;</span>
<span class="holder"><!--&#9711;--></span>
<span class=mainnum><!--CREDIT--></span>
<div class="textblock">
<p>Remaining Flex Dollars:</p>
......
......@@ -6,6 +6,8 @@
#include <cassert>
#include <sstream>
#include <stdexcept>
#include <thread>
#include <chrono>
using namespace std;
vector<string> readHTMLFromFile(string fileName);
......@@ -13,22 +15,33 @@ string getNCKey(vector<string> hLines);
int main() {
system("curl -o THISISATESTFILE https://walla.campuscardcenter.com/ch/login.html");
system("curl -c cookie-jar.txt -o THISISATESTFILE https://walla.campuscardcenter.com/ch/login.html");
//std::this_thread::sleep_for(std::chrono::milliseconds(2000));
vector<string> lines = readHTMLFromFile("THISISATESTFILE");
//Here I need to find the __ncinfo key from the lines returned
string ncInfo = getNCKey(lines);
int numCount = 63 + ncInfo.length();
string countFin = to_string(numCount);
system("curl -o FILETOPARSE -u USERNAME:PASSWORD https://walla.campuscardcenter.com/ch/login.html -s -d __ncinfo=NCINFOKEY ");
string link = "https://walla.campuscardcenter.com/ch";
string syscmd = "curl https://walla.campuscardcenter.com/ch -X POST -b cookie-jar.txt -L --post301 --post302 --post303 -o FILETOPARSE -F \'username=USERNAME\' -F \'password=PASSWORD\' -F \'action=Login\' -F \'__ncforminfo=" + ncInfo + "\' --header \"Accept:text/html\" --header \"Accept-Language:en-US,en;q=0.5\" --compressed --header \"Connection:keep-alive\" --header \"Referer:https://walla.campuscardcenter.com/ch/login.html\" --header \"Content-Length:" + countFin + "\" --header \"Upgrade-Insecure-Requests:1\"";
//cout << syscmd.c_str();
system(syscmd.c_str());
//system("curl \"https://walla.campuscardcenter.com/ch/\" -X GET -c cookie-jar.txt -o FILETOPARSE.html -H \"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\" -H \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" -H \"Accept-Language: en-US,en;q=0.5\" --compressed -H \"Upgrade-Insecure-Requests: 1\" -H \"Connection: keep-alive\""
//);
//system("curl https://walla.campuscardcenter.com/ch/ -b cookie-jar.txt --header \"Accept: text/html\" --header \"Accept-Language: en-US,en;q=0.5\" --compressed --header \"Upgrade-Insecure-Requests: 1\" --header \"Connection: keep-alive\" -o FILETOPARSE");
return 0;
}
//"curl \"https://walla.campuscardcenter.com/ch\" -H \"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\" -H \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" -H \"Accept-Language: en-US,en;q=0.5\" --compressed -H \"Upgrade-Insecure-Requests: 1\" -H \"Connection: keep-alive\""
//"curl \"https://walla.campuscardcenter.com/ch\" -H \"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\" -H \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" -H \"Accept-Language: en-US,en;q=0.5\" --compressed -H \"Upgrade-Insecure-Requests: 1\" -H \"Connection: keep-alive\""
//This is temporary until we get it into your main
vector<string> readHTMLFromFile(string fileName){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment