После краткого обзора http я думаю, что мне понадобится смоделировать браузер, но я не знаю, как это сделать на Java. Веб-сайт, который я пытаюсь использовать.
Поскольку мне нужно очистить исходный код для всех страниц, URL-адрес не меняется при нажатии каждой следующей кнопки. Я использовал Firebug Firefox, чтобы посмотреть, что происходит при нажатии кнопки, но я не знаю всего, что ищу.
Мой код для очистки данных данные на данный момент:
Код: Выделить всё
public class Scraper {
private static String month = "11";
private static String day = "4";
private static String url = "http://cpdocket.cp.cuyahogacounty.us/SheriffSearch/results.aspx?q=searchType%3dSaleDate%26searchString%3d"+month+"%2f"+day+"%2f2013%26foreclosureType%3d%27NONT%27%2c+%27PAR%27%2c+%27COMM%27%2c+%27TXLN%27"; // the input website to be scraped
public static String sourcetext; //The source code that has been scraped
//scrapeWebsite runs the method to scrape the input URL and returns a string to be parsed.
public static void scrapeWebsite() throws IOException {
URL urlconnect = new URL(url); //creates the url from the variable
URLConnection connection = urlconnect.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
connection.getInputStream(), "UTF-8"));
String inputLine;
StringBuilder sourcecode = new StringBuilder(); // creates a stringbuilder which contains the sourcecode
while ((inputLine = in.readLine()) != null)
sourcecode.append(inputLine);
in.close();
sourcetext = sourcecode.toString();
}
Подробнее здесь: https://stackoverflow.com/questions/191 ... -http-post