我正在尝试使用 selenium 将我的网页作为 googlebot 调用。下面是我的代码,但它确实将流量重定向到以 googlebot 身份查看网页...有人可以帮助我以编程方式将我的请求定向到 googlebot 吗?
package com.eviltester.captureNetworkTraffic;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
public class SeleniumTrafficAnalyserExampleTest {
@Test
public void testProfileEvilTester() throws Exception{
// Start the Selenium Server
SeleniumServer srvr = new SeleniumServer();
srvr.start();
// Create a Selenium Session with captureNetworkTraffic ready
String site = "...";//My URL
DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*iexplore", site);
selenium.start("addCustomRequestHeader=true");
selenium.addCustomRequestHeader("User-Agent", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
// open a page to get the traffic
selenium.open("/us/en_us/");
selenium.close();
selenium.stop();
srvr.stop();
}