受Cloudflare保护的网站上的PhantomJS错误

时间:2019-02-06 20:05:48

标签: selenium selenium-webdriver webdriver phantomjs headless-browser

我有一个简单的自动化硒代码,它可以访问网站并执行登录操作。...

WebDriver driver = new PhantomJSDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get("http://upload4earn.org/");
        TimeUnit.SECONDS.sleep(15);
        driver.findElement(By.xpath("//input[@value='Username']")).sendKeys("Jorge");
        driver.findElement(By.xpath("//input[@value='Password']")).sendKeys("test123456");
        driver.findElement(By.xpath("//input[@value='Submit']")).click();
        TimeUnit.SECONDS.sleep(3);

因此,在运行脚本之后,出现以下错误

Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: C:\Users\Nigga\eclipse-workspace\HeadLessBrowser\phantomjs.exe
Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 40366
Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=40366, --webdriver-logfile=C:\Users\Nigga\eclipse-workspace\HeadLessBrowser\phantomjsdriver.log]
Feb 06, 2019 11:55:21 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
[INFO  - 2019-02-06T18:25:25.325Z] GhostDriver - Main - running on port 40366
[INFO  - 2019-02-06T18:25:25.960Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2019-02-06T18:25:25.960Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.customHeaders:  - {}
[INFO  - 2019-02-06T18:25:25.961Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"windows-7-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2019-02-06T18:25:25.961Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 92b8f4f0-2a3c-11e9-844e-25707495b5e3
[ERROR - 2019-02-06T18:25:30.524Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - msg: ReferenceError: Can't find variable: EventTarget

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:30.525Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - stack:
  setupEventListenerProxy (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  t (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:42.108Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - msg: TypeError: undefined is not a constructor (evaluating 'c[Y('0x42')](0,12)')

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:42.109Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - stack:
  (anonymous function) (https://upload4earn.org/:420)

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:54.154Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - msg: ReferenceError: Can't find variable: EventTarget

  phantomjs://platform/console++.js:263 in error
[ERROR - 2019-02-06T18:25:54.155Z] Session [92b8f4f0-2a3c-11e9-844e-25707495b5e3] - page.onError - stack:
  setupEventListenerProxy (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  t (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)
  (anonymous function) (https://ajax.cloudflare.com/cdn-cgi/scripts/cb7744ae/cloudflare-static/rocket-loader.min.js:1)

  phantomjs://platform/console++.js:263 in error

我使用 chrome webdriver 尝试了此脚本,并且运行良好,并且我还检查了是否启用了javascript,并且默认情况下启用了该脚本,还添加了15秒的睡眠时间以等待是否有cloudflare检查ddos。 并且还尝试在网络上检查解决方案,但是找不到任何解决方案。

0 个答案:

没有答案