[英]jsoup is not getting some html tags from a webpage
我正在嘗試使用 JSOUP 從網頁中獲取 SELECT 節點。 我遇到的問題是我只是在 SELECT 節點中獲得了第一個 OPTION 節點。 當我查看上述網頁的 html 源代碼時,我看到 SELECT 節點內部有 9 個 OPTION 節點。 這是我正在使用的 java 代碼:
Document doc;
Elements stops;
try {
doc = Jsoup
.connect("http://www.miamidade.gov/transit/mobile/scriptCheck.asp?
script=yes&CurrentPage=/transit/mobile/schedules.asp?route=3")
.userAgent(" Mozilla/5.0")
.timeout(30000)
.get();
stops = doc.getElementsByTag("select");
for (Element option : stops) {
System.out.print(option.text());
}
} catch (IOException e) {
e.printStackTrace();
}
如果您只是 go 直接訪問所注明的網頁,您會得到一個帶有單個選項(“-”)的 select 元素。 為了獲得所有選項,您需要將 go 返回到http://www.miamidade.gov/transit/mobile/routes.asp?route=3
並單擊“查看時間表”。 我猜為了讓它工作,你首先必須發送那個 POST 請求才能獲得 select 將所有的選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.