にフォームタグが埋め込まれています。私の目標はこのURL http://eaacorp.com/find-a-dealerにアクセスし、javaを使用してフォームに記入することです。JavaScriptを使用してウェブサイトのフォームに記入しようとしましたが、iframeタグ
<iframe id="blockrandom" name="iframe" src="http://www.eaacorp.com/dealer/searchdealer.php" width="100%" height="500" scrolling="auto" frameborder="1" class="wrapper"></iframe>
:formタグがiframeタグ(ページのソースの抜粋)にhttp://www.eaacorp.com/dealer/searchdealer.php HTMLに埋め込まれているため
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class HttpUrlConnectionExample{
public static void main(String[] args) throws IOException{
Document document = Jsoup.connect("http://eaacorp.com/find-a-dealer").get();
String page = document.toString();//this is the whole page's html
Elements formEl = document.getElementsByTag("form");
}
}
しかしformElは空を返します。これを行うには、私はすべてのフォームタグを見つけることを試みしたがって、iframeタグ内のformタグにアクセスする方法はありますか?ような何か:
if(formEl.isEmpty()){
//find iframe
Elements iframeEl = document.getElementsByTag("iframe");
System.out.println(iframeEl);
String embedURL = iframeEl.getSrc();//DOES NOT COMPILE, getSrc() is not a method
Document embedDoc = Jsoup.connect(embedURL).get();
}