So I'm currently trying to scrape all the data from (http://games.espn.go.com/ffl/leaders?) and store it. The current approach I have is just ripping the site them extracting all data from it. However, after seeing how inefficient this is, I started to do some research on JSOUP. I managed to find this stackoverflow post about using JSOUP with espn. Using JSoup To Extract HTML Table Contents. I tried using the same approach however I have no idea what to do to get all the table info from http://games.espn.go.com/ffl/leaders?. Any help is much appreciated!
Asked
Active
Viewed 779 times
0
-
You need to be more specific. What problem you are facing? What work you've done so far to solve that problem? What difficulty you are having while solving it? – Pshemo Oct 08 '15 at 23:19
-
I have no idea where to start. Not familiar with Jsoup at all. Tried reading up on the documentation but I've had no luck. Basically I'm trying to get the player name / team / stats/ and fantasy points. – Raymond.Aggarwal Oct 08 '15 at 23:46
-
Start here http://jsoup.org/cookbook/extracting-data/selector-syntax – Pshemo Oct 08 '15 at 23:46
-
I kind of have a rough idea of what I'm doing now. The code I have is a copy from the post I linked in the original post. The problem I am facing now is that when I change the table name to playerTableTable tableBody, nothing happens – Raymond.Aggarwal Oct 09 '15 at 03:52
1 Answers
0
Document doc = Jsoup
.connect("http://games.espn.go.com/ffl/leaders")
.userAgent(
"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36")
.ignoreContentType(true).timeout(0).get();
Elements elements = doc.select("table[class=playerTableTable tableBody]");
Elements rows = elements.get(0).select("tr[class^=pncPlayerRow]");
for (Element row : rows) {
Elements tds = row.select("td");
if(tds.size() != 24) continue;
String mPLAYERTEAMPOS = tds.get(0).text();
String mWK_OPP = tds.get(2).text();
String mWK_STATUSET = tds.get(3).text();
String mPASSING_CA = tds.get(5).text();
String mPASSING_YDS = tds.get(6).text();
String mPASSING_TD = tds.get(7).text();
String mPASSING_INT = tds.get(8).text();
String mRUSHING_RUSH = tds.get(10).text();
String mRUSHING_YDS = tds.get(11).text();
String mRUSHING_TD = tds.get(12).text();
String mRECEIVING_REC = tds.get(14).text();
String mRECEIVING_YDS = tds.get(15).text();
String mRECEIVING_TD = tds.get(16).text();
String mRECEIVING_TAR = tds.get(17).text();
String mMISC_2PC = tds.get(19).text();
String mMISC_FUML = tds.get(20).text();
String mMISC_TD = tds.get(21).text();
String mTOTAL_PTS = tds.get(23).text();
System.out.println("mPLAYERTEAMPOS\t\t\t"+ mPLAYERTEAMPOS);
System.out.println("mWK_OPP \t\t\t"+mWK_OPP);
System.out.println("mWK_STATUSET\t\t\t" + mWK_STATUSET);
System.out.println("mPASSING_CA\t\t\t"+mPASSING_CA);
System.out.println("mPASSING_YDS\t\t\t"+mPASSING_YDS);
System.out.println("mPASSING_TD\t\t\t"+mPASSING_TD);
System.out.println("mPASSING_INT\t\t\t"+mPASSING_INT);
System.out.println("mRUSHING_RUSH\t\t\t"+mRUSHING_RUSH);
System.out.println("mRUSHING_YDS\t\t\t"+mRUSHING_YDS);
System.out.println("mRUSHING_TD\t\t\t"+mRUSHING_TD);
System.out.println("mRECEIVING_REC\t\t\t"+mRECEIVING_REC);
System.out.println("mRECEIVING_YDS\t\t\t"+mRECEIVING_YDS);
System.out.println("mRECEIVING_TD\t\t\t"+mRECEIVING_TD);
System.out.println("mRECEIVING_TAR\t\t\t"+mRECEIVING_TAR);
System.out.println("mMISC_2PC\t\t\t"+mMISC_2PC);
System.out.println("mMISC_FUML\t\t\t"+mMISC_FUML);
System.out.println("mMISC_TD\t\t\t"+mMISC_TD);
System.out.println("mTOTAL_PTS\t\t\t"+mTOTAL_PTS);
}

Hasanaga
- 1,099
- 1
- 9
- 19