日期:2014-05-20  浏览次数:20692 次

我想做个小外挂,可以自动打开网页,点击某些固定链接,很简单的
本帖最后由 wozhuibenle 于 2014-02-26 20:09:08 编辑
不知道我应该学点什么呢,用什么环境呢
哪位大哥帮指点一下哈,谢谢了
如果推荐本书就更好了。
------解决方案--------------------
点击链接也就是发送请求而已,java和.Net应该就可以了,容易上手
------解决方案--------------------
用Java的测试工具:Selenium + JUnit 
可以打开网页,点击网页上的链接。
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class SeleniumTest {
    protected WebDriver driver;

    @Before
    public void setUp() {
        driver = new SafariDriver();
    }

    @After
    public void cleanUp() {
        // Close the browser
        driver.quit();
    }

    @Test
    public void search() {
        // And now use this to visit Baidu
        driver.get("http://www.baidu.com");
        // Alternatively the same thing can be done like this
        // driver.navigate().to("http://www.google.com");

        // Find the text input element by its id
        WebElement element = driver.findElement(By.id("kw"));

        // Enter something to search for
        element.sendKeys("Cheese!");

        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        // Now submit the form. WebDriver will find the form for us from the element
        // driver.findElement(By.id("su")).click();
        element.submit();

        // Baidu's search is rendered dynamically with JavaScript.
        // Wait for the page to load, timeout after 20 seconds
        (new WebDriverWait(driver, 20)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver driver) {
                return driver.getTitle().toLowerCase().startsWith("cheese!");
            }
        });

        // Should see: "Cheese!_百度搜索"
        System.out.println("Page title is: " + driver.getTitle());
    }
}

------解决方案--------------------
用Selenium可以实现楼主需求,就是一个测试软件。。。
------解决方案--------------------
public class SeleniumTest {
    protected WebDriver driver;
 
    @Before
    public void setUp() {
     System.setProperty("webdriver.ie.bin","C:\\Program Files\\Internet Explorer\\iexplore.exe");
     try{
     driver= new InternetExplorerDriver();
       // driver = new FirefoxDriver();
     }catch (Exception e) {
e.printStackTrace();
}
    }
 
    @After
    public void cleanUp() {
        // Close the browser
        driver.quit();
    }
 
    @Test
    public void search() {
     //DefaultSelenium selenium = new DefaultSelenium( "localhost" , 4444, "*firefox D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe","http://www.baidu.com");
       driver.get("http://www.baidu.com");