1
我想使用硒来调用我的网页作为googlebot。下面是我的代码,但它确实重定向流量,以查看网页为googlebot ...有人可以帮助我指示我的请求以googlebot编程?useragent 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();
}