Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using JSOUP API to scrape the contents of the webpage.I am attaching the html source code and Java source code which i have tried.

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("..............................................");
The output iam getting is
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
..............................................




Now i am attaching the html source code
which i am not able to scrpe
<div id="sur_collection_25">
<div class="collectionHdr" id = "collection25Hdr">
<span class="collectionName" id = "collection25NameShow">
<a style="text-decoration: none;" href = "Javascript:toggleEvCol('collection25' , 25, '4509085');" >Goals</a>
</span>
<span class="collectionName displayNone" id = "collection25NameHide" style="color: #777777;">
Goals
</span>
<a class = "collectionShowLink displayInlineBlock" href = "Javascript:expandCollection('collection25', 25, '4509085')" id = "collection25Show" >Show All <span id = "collection25NumMkts" >30</span> Markets</a>
<a class = "collectionHideLink displayInlineBlock displayNone" href = "Javascript:collapseCollection('collection25')" id = "collection25Hide"
>Collapse</a>
<a class = "collectionWaitLink displayInlineBlock displayNone" id = "collection25Wait" ></a>
</div>

<div id="collection25" class="collectionContainer displayNone"></div>
<div class="clearBoth"></div>
<div class="collectionFtr"></div>
</div>
My Actual Requirement is i want to scrape all the tab names of the page like Match Betting,Correct Score,etc.For the attached html source code i am having 52 tabs.The problem occurs in the third part of the tag as you can see in the output.It should return St Patricks To Score Both Halves ,Limerick To Score Both Halves .etc .It is returning null values.I am not able to scrape.I want to know the reason behind that.Please help me.It is needed very urgently.They are updating the site frequently.If it is not having any tabs .Please inform me .i will mention the different url.
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic