-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Change code to spawn browser to be more human likely"
This reverts commit 4970fa1.
- Loading branch information
1 parent
4970fa1
commit dccac02
Showing
4 changed files
with
31 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
package com.desolator | ||
|
||
import com.desolator.helpers.login | ||
import com.desolator.lib.dinkIt | ||
import com.desolator.utils.initBrowser | ||
import org.jsoup.Connection | ||
import org.jsoup.Jsoup | ||
import java.util.* | ||
|
||
object Main { | ||
@JvmStatic | ||
// dinkit [email] [password] [product detail url] | ||
fun main(args: Array<String>) { | ||
val (email, password, productDetailUrl) = args | ||
val driver = initBrowser(true) | ||
|
||
try { | ||
login(driver, email, password) | ||
dinkIt(driver, productDetailUrl) | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
} finally { | ||
driver.close() | ||
if (args.size < 3) { | ||
println("Should email password and product id to execute!") | ||
return | ||
} | ||
|
||
val (email, password, productId) = args | ||
val tokopediaLoginUrl = Jsoup.connect("https://www.tokopedia.com/login").followRedirects(true).execute() | ||
val headers = hashMapOf( | ||
"content-type" to "application/x-www-form-urlencoded", | ||
"origin" to "https://accounts.tokopedia.com", | ||
"referer" to tokopediaLoginUrl.url().toString(), | ||
"user-agent" to "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54" | ||
) | ||
|
||
val loginRes = Jsoup.connect(tokopediaLoginUrl.url().toString()) | ||
.headers(headers) | ||
.cookies(tokopediaLoginUrl.cookies()) | ||
.data("email", email, "password", password, "remember_me", "on") | ||
.method(Connection.Method.POST) | ||
.execute() | ||
|
||
val milliseconds = Calendar.getInstance().timeInMillis | ||
val dinkItUrl = "https://www.tokopedia.com/ajax/product-e4.pl?action=event_dink_it&p_id=${productId}&v=${milliseconds}" | ||
val dinkItResult = Jsoup | ||
.connect(dinkItUrl) | ||
.cookies(loginRes.cookies()) | ||
.get() | ||
|
||
println(dinkItResult) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.