Document document = Jsoup .connect( "http://sports.williamhill.com/bet/en-gb/betting/e/4509085/St-Patricks-v-Limerick.html") .timeout(1000 * 1000).get(); Elements content = document.select("div.livePushContent"); Elements info = content.select("div#allMarketsTab"); Elements primerycollect = info.select("div#primaryCollectionContainer"); System.out.println("1.............................................."); System.out.println("No of Tab's: " + info.select("div#primaryCollectionContainer") .select("div.marketHolderExpanded").size()); Elements market = primerycollect.select("table.tableData"); Elements tbody = market.select("tbody"); for (int i = 0; i < info.select("div#primaryCollectionContainer") .select("div.marketHolderExpanded").size(); i++) { int a = 1; a+=i; System.out.println("Tab No"+a+": "+info.select("div#primaryCollectionContainer") .select("div.marketHolderExpanded").get(i) .select("table.tableData").select("thead").select("tr") .select("th[class~=leftPad title]").select("span").last().text()); } Elements primerycollect1 = info.select("div#sur_collection_267"); System.out.println(".............................................."); System.out.println("2.............................................."); System.out.println("No of Tab's: " + info.select("div#sur_collection_267") .select("div.marketHolderExpanded").size()); Elements market1 = primerycollect1.select("table.tableData"); Elements tbody1 = market1.select("tbody"); for (int i = 0; i < info.select("div#sur_collection_267") .select("div.marketHolderExpanded").size(); i++) { System.out.println("Tab No"+i+++": "+info.select("div#sur_collection_267") .select("div.marketHolderExpanded") .select("table.tableData") .select("thead").select("tr") .select("th[class~=leftPad title]").select("span").last().text()); } System.out.println("3.............................................."); System.out.println("No of Tab's: " + info.select("div#sur_collection_25") .select("div#collection25").size()); Elements primerycollect2 = info.select("div#sur_collection_25"); Elements market2 = primerycollect2.select("table.tableData"); Elements tbody2 = market2.select("tbody"); for (int i = 0; i < info.select("div#sur_collection_25") .select("div#collection25").size(); i++) { System.out.println("Tab No"+i+": "+info.select("div#sur_collection_25") .select("div.collectionContainer displayBlock displayNone") .select("div.marketHolderCollapsed").get(i) .select("table.tableData").select("thead").select("tr") .select("th[class~=leftPad title]").select("span").last().text()); } System.out.println("..............................................");
1.............................................. No of Tab's: 10 Tab No1: Match Betting Tab No2: Correct Score Tab No3: Double Result Tab No4: Draw No Bet Tab No5: Match Handicaps Tab No6: Double Chance Tab No7: Both Teams To Score Tab No8: 1st Half Betting Tab No9: 2nd Half Betting Tab No10: Total Match Goals Under/Over .............................................. 2.............................................. No of Tab's: 1 Tab No0: GOAL scored in the first 5 minutes? 00:00 - 04:59 3.............................................. No of Tab's: 1 Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at org.jsoup.select.Elements.get(Elements.java:523) at com.yotechnologies.scraper.williamhill.test.Trial3.main(Trial3.java:67)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)