我基本上需要在this site上向我的所有朋友发送推荐请求。页面外观如下(登录后):
我需要在文本框中一个接一个的输入编号,我可能想通过脚本在所有编号上运行一个循环来自动执行脚本。卷号的格式为10 / CSE / XX,其中XX的范围为(1,92)。我该怎么做?
这是html源代码中的特定部分。
<div class="row">
<div class="span9">
<h2>Request New Testimonial</h2>
<form name="request" action="requesttestimonial.php" method="POST">
<input type="text" name="requestroll" placeholder="Roll number of the person you want to request a testimonial" />
<input type="submit" value="Send Request" name="submitrequest" />
</form>
</div>
</div>
登录页面:
<form class="navbar-form pull-right" method="POST" action="login.php">
<input class="span2" name="rollnumber" type="text" placeholder="Roll Number">
<input class="span2" name="password" type="password" placeholder="Password">
<button type="submit" class="btn" name="signin">Sign in</button>
</form>
任何语言都可以。
最佳答案
您可以使用Java的Selenium包。它很简单,并且支持各种HTML控件,除非您正在寻找特定于python的东西,在这种情况下,请忽略我的回答
编辑:
package org.openqa.selenium.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Example {
public static void main(String[] args) {
// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new HtmlUnitDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
示例取自http://code.google.com/p/selenium/wiki/GettingStarted,足以满足您的需求