防检测脚本: stealth.min.js
package com.kakuiwong;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.locks.LockSupport;
public class App {
public static void main(String[] args) throws IOException {
String read = read();
try (Playwright playwright = Playwright.create()) {
BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions();
launchOptions.setChannel("chrome");
launchOptions.setHeadless(false);
Browser browser = playwright.chromium().launch(launchOptions);
Page page = browser.newPage();
page.addInitScript(read);
page.navigate("https://bot.sannysoft.com/");
System.out.println(page.title());
LockSupport.park();
}
}
public static String read() throws IOException {
InputStream resourceAsStream = App.class.getClassLoader().getResourceAsStream("site-digger.com_uploads_stealth.min.js");
int n = 0;
byte[] buffer = new byte[4096];
ByteArrayOutputStream output = new ByteArrayOutputStream();
while (-1 != (n = resourceAsStream.read(buffer))) {
output.write(buffer, 0, n);
}
output.flush();
String text = output.toString();
resourceAsStream.close();
output.close();
return text;
}
}
本文由 GY 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
2023/08/09 14:24