@ -0,0 +1,28 @@ | |||||
package net.jrtechs.www.webCrawler; | |||||
import java.util.Calendar; | |||||
/** | |||||
* @author Jeffery Russell | |||||
*/ | |||||
public class APIThrottler | |||||
{ | |||||
public int totalqueries; | |||||
private long lastQuery; | |||||
boolean queryAvailable() | |||||
{ | |||||
return true; | |||||
} | |||||
public long getCurrentTimeInMS() | |||||
{ | |||||
Calendar calendar = Calendar.getInstance(); | |||||
//Returns current time in millis | |||||
long timeMilli2 = calendar.getTimeInMillis(); | |||||
return timeMilli2; | |||||
} | |||||
} |
@ -0,0 +1,59 @@ | |||||
package net.jrtechs.www.webCrawler; | |||||
import com.google.gson.Gson; | |||||
import net.jrtechs.www.server.Player; | |||||
/** | |||||
* File which handles the file IO for storing | |||||
* all the players on the HHD | |||||
* | |||||
* @author Jeffery Russell 11-18-18 | |||||
*/ | |||||
public class FileIO | |||||
{ | |||||
/** Base directory to store all the data */ | |||||
private String baseFilaPath; | |||||
/** Object used to convert objects to json strings */ | |||||
private final Gson gson; | |||||
/** | |||||
* Initalizes the base directory | |||||
* @param basePath | |||||
*/ | |||||
public FileIO(String basePath) | |||||
{ | |||||
this.baseFilaPath = basePath; | |||||
this.gson = new Gson(); | |||||
} | |||||
/** | |||||
* Determines if we already have the player | |||||
* on disk. | |||||
* | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
public boolean playerExists(String id) | |||||
{ | |||||
return false; | |||||
} | |||||
/** | |||||
* Writes the player to the file. | |||||
* | |||||
* @param player | |||||
*/ | |||||
public void writeToFile(Player player) | |||||
{ | |||||
String data = gson.toJson(player); | |||||
String fileName = baseFilaPath + player.getId() + ".json"; | |||||
SteamdFileWriter.writeToFile(data, fileName); | |||||
} | |||||
} |
@ -0,0 +1,34 @@ | |||||
package net.jrtechs.www.webCrawler; | |||||
import net.jrtechs.www.SteamAPI.APIConnection; | |||||
import java.io.File; | |||||
/** | |||||
* Main class for digging up the entire | |||||
* steam network. | |||||
* | |||||
* @author Jeffery Russell | |||||
*/ | |||||
public class SteamWebCrawler | |||||
{ | |||||
private APIThrottler throttler; | |||||
private APIConnection connection; | |||||
private FileIO fileIO; | |||||
public void runSteamCrawler(String baseID) | |||||
{ | |||||
} | |||||
public static void main(String args[]) | |||||
{ | |||||
new SteamWebCrawler().runSteamCrawler("76561198188400721"); | |||||
} | |||||
} |
@ -0,0 +1,27 @@ | |||||
package net.jrtechs.www.webCrawler; | |||||
import java.io.BufferedWriter; | |||||
import java.io.File; | |||||
import java.io.FileWriter; | |||||
public class SteamdFileWriter | |||||
{ | |||||
public static void writeToFile(String data, String fileName) | |||||
{ | |||||
BufferedWriter writer; | |||||
try | |||||
{ | |||||
File file = new File(fileName); | |||||
file.createNewFile(); | |||||
writer = new BufferedWriter(new FileWriter(file)); | |||||
writer.write(data); | |||||
writer.flush(); | |||||
writer.close(); | |||||
System.out.println("Wrote to " + fileName); | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
} |