0

I'm making a Java app that goes to Southwest.com and searches for a particular flight 4 times a day. If it finds a cheap flight, it e-mails the user.

I need to know how to input the data on the Southwest.com homepage (i.e. that I want a flight from JFK to SFO on 7/24/2011), so that I can scrape the HTML from the results page to deliver the lowest price.

Any help on how you would query the site in Java would be greatly appreciated.

4

2 回答 2

3

预先警告,你是在他们的网站架构师和设计师的心血来潮的摆布。我知道,我花了一年的时间为一家在线零售企业做同样的事情。

使用 HTTPUnit,它将页面呈现在内存中,您可以检索将内容发布到站点所需的文本和 url。确保保存他们页面的内容以进行调试和记录。

使用您通过 HTTPUnit 检索到的信息来构建 url 和 Form 对象以发回他们的站点。

祝你好运!

于 2011-04-02T21:19:34.643 回答
1

查看 HTTPRequests。基本上,这些字段将通过 GET 或 POST 参数发送。

参数的格式通常如下:

¶m1=JFK¶m2=某个值...

使用 GET 方法,您可以将参数附加到 URL 的末尾,如下所示:www.site.com?param1=JFD¶m2=...

使用 POST,您必须将参数作为 URL 之后的流发送。

您可以使用的 Java 类是:http: //download.oracle.com/javase/1.4.2/docs/api/java/net/HttpURLConnection.html

于 2011-04-02T21:17:45.543 回答