Beispiele für Dramatiker Puppenspieler-Extra-Plugin-Stealth-Beispiel, bei dem Firefox nicht beendet istJava

Java-Forum
Anonymous
 Beispiele für Dramatiker Puppenspieler-Extra-Plugin-Stealth-Beispiel, bei dem Firefox nicht beendet ist

Post by Anonymous »

Ich habe einen Java -Code, der ein Knotenausschnitt wie dieses ausführt, was sehr einfach ist: < /p>

Code: Select all

public void executeCommand(){
try{
System.out.println(command);
final long startTime = System.currentTimeMillis();
final Process p = Runtime.getRuntime().exec(command);
//final boolean done = p.waitFor(10, TimeUnit.SECONDS);
System.out.println("WAITING FOR THE COMMAND TO RESPOND. ");
final Streamdata = new BufferedReader(new InputStreamReader(p.getInputStream())).lines().peek(System.out::println);
System.out.println("Step--->1");
final Listlines = data.collect(Collectors.toList());
System.out.println("Step--->2");
final long endTime = System.currentTimeMillis();
if(lines.isEmpty()){
System.out.println("empty response"+" in:"+(endTime-startTime)+" ms.");
}else{
System.out.println("lines = " + lines.size()+" in:"+(endTime-startTime)+" ms.");
lines.forEach(System.out::println);
//System.out.println("lines = " + lines.size()+" in:"+(endTime-startTime)+" ms.");
}
}catch(final Exception e){
e.printStackTrace();
}
}
< /code>
Die Befehlsvariable ist so etwas wie: < /p>
private final String command  = "node C:\\Users\\chipe\\Desktop\\EjemploConChrome.js";
< /code>
Und die Datei ist so etwas. In der Tat ist dies nur eine Ähnlichkeit mit dem offiziellen Plugin -Testcode: < /p>
// playwright-extra is a drop-in replacement for playwright,
// it augments the installed playwright with plugin functionality
const { chromium } = require('playwright-extra')

// Load the stealth plugin and use defaults (all tricks to hide playwright usage)
// Note: playwright-extra is compatible with most puppeteer-extra plugins
const stealth = require('puppeteer-extra-plugin-stealth')()

// Add the plugin to playwright (any number of plugins can be added)
chromium.use(stealth)

// That's it, the rest is playwright usage as normal 😊
chromium.launch({ headless: false }).then(async browser => {
const page = await browser.newPage()

console.log('Testing the stealth plugin..')
await page.goto('https://bot.sannysoft.com', { waitUntil: 'networkidle' })
await page.screenshot({ path: 'stealth.png', fullPage: true })

console.log('All done, check the screenshot. ✨')
await browser.close()
})
Wenn ich ausgeführt habe, funktioniert es korrekt:

, aber wenn ich die Firefox -Version von der Firefox ausführte, nur mit der Firefox -Version von der Firefox ausführte. Firefox :

Code: Select all

// playwright-extra is a drop-in replacement for playwright,
// it augments the installed playwright with plugin functionality
const { firefox } = require('playwright-extra')

// Load the stealth plugin and use defaults (all tricks to hide playwright usage)
// Note: playwright-extra is compatible with most puppeteer-extra plugins
const stealth = require('puppeteer-extra-plugin-stealth')()

// Add the plugin to playwright (any number of plugins can be added)
firefox.use(stealth)

// That's it, the rest is playwright usage as normal 😊
firefox.launch({ headless: false }).then(async browser => {
const page = await browser.newPage()

console.log('Testing the stealth plugin..')
await page.goto('https://bot.sannysoft.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'stealth.png', fullPage: true })
console.log('All done, check the screenshot. ✨')
await browser.close()
})
< /code>
Ich kann das Start von 2 Browsern anstelle von 1 sehen, aber ich weiß nicht warum. Aber wenn ich den Befehl direkt in der Befehlszeile ausführe, ist er fertig, aber ich brauche ihn in java. < /P>
Der Browser bleibt offen und in dieser Zeile.await page.goto('https://bot.sannysoft.com', { waitUntil: 'networkidle' });
und das Netzwerk ist in Leerlauf.
Was mache ich falsch? src = "https://i.Sstatic.net/n1chs.png"/>
Herunterfahren Sie manuell:

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post