Skip to content

Commit

Permalink
author block-code and description added to each class
Browse files Browse the repository at this point in the history
  • Loading branch information
jetkai committed Feb 17, 2023
1 parent 32619ac commit 7f307e4
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CheckerProxy : Plugin, ProxyWebsite {
logger.error { ex.message }
}

return false
return true
}

override fun thenConnect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FreeProxyApi : Plugin, ProxyWebsite {
logger.error { ex.message }
}

return false
return true
}

override fun thenConnect() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/plugin/httpclient/geonode/GeoNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class GeoNode : Plugin, ProxyWebsite {
logger.error { ex.message }
}

return false
return true
}

override fun thenConnect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OpenProxyList : Plugin, ProxyWebsite {
logger.error { ex.message }
}

return false
return true
}

override fun thenConnect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ProxyScrape : Plugin, ProxyWebsite {
logger.error { ex.message }
}

return false
return true
}

override fun thenConnect() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/scraper/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import java.nio.file.Path
import kotlin.io.path.exists
import kotlin.system.exitProcess

/**
* Main - 12/02/2023
* @author Kai
*
* Description: Main class, runs the application
**/
class Main {

private val logger = KotlinLogging.logger { }
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/scraper/net/ChromeWebDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import org.openqa.selenium.devtools.Command
import org.openqa.selenium.devtools.DevTools
import org.openqa.selenium.devtools.v109.network.Network

/**
* ChromeWebDriver - 12/02/2023
* @author Kai
*
* Description: Used for more complex proxy sites, ones that require JavaScript & obfuscate their data
**/
class ChromeWebDriver {

private val options = ChromeOptions()
Expand Down
17 changes: 12 additions & 5 deletions src/main/kotlin/scraper/net/CoroutinesHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@ import java.net.http.HttpResponse
import java.net.http.HttpTimeoutException
import java.time.Duration


/**
* CoroutinesHttpClient - 12/02/2023
* @author Kai
*
* Description: Used for simple web calls, such as sending GET/POST data for text content (JSON etc)
**/
class CoroutinesHttpClient {

companion object {

val timeout : Duration = Duration.ofSeconds(15)

private val httpClient : HttpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.connectTimeout(Duration.ofSeconds(30))
.version(HttpClient.Version.HTTP_2)
.connectTimeout(timeout)
.build()

}
Expand All @@ -31,7 +38,7 @@ class CoroutinesHttpClient {
val request : HttpRequest = if(postData == null) {
HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(30))
.timeout(timeout)
.headers(*userAgent)
.headers(*accept)
.headers(*acceptLanguage)
Expand All @@ -42,7 +49,7 @@ class CoroutinesHttpClient {
} else {
HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(30))
.timeout(timeout)
.headers(*userAgent)
.headers(*accept)
.headers(*acceptLanguage)
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/scraper/plugin/Plugin.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package scraper.plugin

/**
* Plugin - 12/02/2023
* @author Kai
*
* Description: Interface for Plugin, this will append the class to a List within PluginFactory
**/
interface Plugin {

fun register()
Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/scraper/plugin/PluginFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import org.reflections.Reflections
import scraper.plugin.hook.ProxyWebsite
import java.lang.reflect.Modifier

/**
* PluginFactory - 12/02/2023
* @author Kai
*
* Description: This is used for loading the Proxy Website Plugins from /src/main/kotlin/plugins/
* Makes it easier for APIs to be added / removed
**/
object PluginFactory {

private val logger = KotlinLogging.logger { }
Expand Down
7 changes: 7 additions & 0 deletions src/main/kotlin/scraper/plugin/hook/ProxyWebsite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package scraper.plugin.hook

import scraper.util.data.ProxyData

/**
* ProxyWebsite - 12/02/2023
* @author Kai
*
* Description: Interface for the Website Plugins within /src/main/kotlin/plugin/
* Plugins will follow this interface format
**/
interface ProxyWebsite {

val proxies : MutableList<ProxyData>
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/scraper/util/NetworkUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package scraper.util

import java.util.regex.Pattern

/**
* NetworkUtils - 17/02/2023
* @author Kai
*
* Description: Any reusable network functions are in this class
**/
object NetworkUtils {

fun isValidIpAddress(ipAddress : String) : Boolean {
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/scraper/util/ScraperExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package scraper.util
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors

/**
* ScraperExecutor - 17/02/2023
* @author Kai
*
* Description: This is used for multi-threading to speed up the application
**/
object ScraperExecutor {

private val PROCESSORS = Runtime.getRuntime().availableProcessors() + 1
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/scraper/util/ScraperThreadFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package scraper.util
import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger

/**
* ScraperThreadFactory - 12/02/2023
* @author Kai
*
* Description: This is used for multi-threading to speed up the application
**/
class ScraperThreadFactory(private val name : String) : ThreadFactory {
private val threadCount = AtomicInteger()
override fun newThread(r : Runnable): Thread {
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/scraper/util/scripts/GetAllCheckerProxies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import java.time.format.DateTimeFormatter
import kotlin.io.path.exists
import kotlin.system.exitProcess

/**
* GetAllCheckerProxies - 17/02/2023
* @author Kai
*
* Description: Quick and easy script for getting all the proxies from CheckerProxy's API
**/
private const val endpoint = "https://checkerproxy.net/api/archive/"

private val proxies : MutableList<ProxyData> = mutableListOf()
Expand All @@ -26,7 +32,7 @@ fun main() {
loopThroughDates()
}

fun loopThroughDates() {
private fun loopThroughDates() {
val format = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val fromDate = LocalDate.parse("2023-01-18", format)
val toDate = LocalDate.parse("2023-02-17", format)
Expand Down

0 comments on commit 7f307e4

Please sign in to comment.