@@ -1972,8 +1972,7 @@ private static String getNameFromPage(Document doc) {
19721972 */
19731973 private static String getRealmFromPage (Document doc ) {
19741974 //Get elements in the player name area
1975- Elements elements = doc .getElementsByClass ("player_name_txt" );
1976- String realmName = elements .get (0 ).getElementsByTag ("span" ).text ().replace ("(" , "" ).replace (")" , "" );
1975+ String realmName = doc .getElementsByClass ("frame__chara__world" ).get (0 ).text ().replace ("(" , "" ).replace (")" , "" );
19771976 //Return the realm name (contained in span)
19781977 return realmName ;
19791978 }
@@ -1985,7 +1984,7 @@ private static String getRealmFromPage(Document doc) {
19851984 * @return the race of the character.
19861985 */
19871986 private static String getRaceFromPage (Document doc ) {
1988- return doc .getElementsByClass ("chara_profile_title " ).get (0 ).text ().split ( Pattern . quote ( "/" ))[ 0 ] .trim ();
1987+ return doc .getElementsByClass ("character-block__name " ).get (0 ).textNodes ().get ( 0 ). text () .trim ();
19891988 }
19901989
19911990 /**
@@ -1995,8 +1994,8 @@ private static String getRaceFromPage(Document doc) {
19951994 * @return the gender of the character.
19961995 */
19971996 private static String getGenderFromPage (Document doc ) {
1998- String [] parts = doc .getElementsByClass ("chara_profile_title " ).get (0 ).text ().split (Pattern .quote ("/" ));
1999- String gender = parts [2 ].trim ();
1997+ String [] parts = doc .getElementsByClass ("character-block__name " ).get (0 ).text ().split (Pattern .quote ("/" ));
1998+ String gender = parts [1 ].trim ();
20001999 if (gender .equals ("♂" )) {
20012000 return "male" ;
20022001 } else if (gender .equals ("♀" )) {
@@ -2016,23 +2015,20 @@ private static String getGrandCompanyFromPage(Document doc) {
20162015 String gc = null ;
20172016 String fc = null ;
20182017 //Get all elements with class chara_profile_box_info
2019- Elements elements = doc .getElementsByClass ("txt_name" );
2020-
2021- //Checks to see if optional FC has been added
2018+ Elements elements = doc .getElementsByClass ("character-block__box" );
20222019 if (elements .size () == 5 ) {
2023- fc = elements .get (4 ). getElementsByTag ( "a " ).text ();
2020+ gc = elements .get (3 ). getElementsByClass ( "character-block__name " ).get ( 0 ). text (). split ( "/" )[ 0 ]. trim ();
20242021 }
2025-
2026- if (elements .size () == 5 ) { //If GC and FC present
2027- gc = elements .get (3 ).text ().split (Pattern .quote ("/" ))[0 ];
2028- } else if (elements .size () == 4 ) { //If only GC present
2029- gc = elements .get (3 ).text ().split (Pattern .quote ("/" ))[0 ];
2030- if (!gc .equals ("Immortal Flames" ) && !gc .equals ("Order of the Twin Adder" ) && !gc .equals ("Maelstrom" )) { //If not a valid GC
2022+ else if (elements .size () == 4 ) {
2023+ if (elements .get (3 ).getElementsByClass ("character__freecompany__name" ).size () > 0 ) { //If box is fc
20312024 gc = "none" ;
2025+ } else {
2026+ gc = elements .get (3 ).getElementsByClass ("character-block__name" ).get (0 ).text ().split ("/" )[0 ].trim ();
20322027 }
2033- } else if ( elements . size () == 3 ) {
2028+ } else {
20342029 gc = "none" ;
20352030 }
2031+
20362032 return gc ;
20372033 }
20382034
@@ -2046,21 +2042,19 @@ private static String getFreeCompanyFromPage(Document doc) {
20462042 String gc = null ;
20472043 String fc = null ;
20482044 //Get all elements with class chara_profile_box_info
2049- Elements elements = doc .getElementsByClass ("txt_name " );
2045+ Elements elements = doc .getElementsByClass ("character-block__box " );
20502046
20512047 //Checks to see if optional FC has been added
20522048 if (elements .size () == 5 ) {
2053- fc = elements .get (4 ).getElementsByTag ("a" ).text ();
2049+ fc = elements .get (4 ).getElementsByClass ( "character__freecompany__name" ). get ( 0 ). getElementsByTag ("a" ).text ();
20542050 } else if (elements .size () == 4 ) { //If only 4 elements present
2055- //Assume that gc is what is in slot 3
2056- gc = elements .get (3 ).text ().split (Pattern .quote ("/" ))[0 ];
2057- if (!gc .equals ("Immortal Flames" ) && !gc .equals ("Order of the Twin Adder" ) && !gc .equals ("Maelstrom" )) { //If not a valid GC
2058- gc = "none" ;
2059- fc = elements .get (3 ).text ().split (Pattern .quote ("/" ))[0 ];
2060- } else {
2061- fc = "none" ;
2051+
2052+ if (elements .get (3 ).getElementsByClass ("character__freecompany__name" ).size () > 0 ) { //If box is fc
2053+ fc = elements .get (3 ).getElementsByClass ("character__freecompany__name" ).get (0 ).getElementsByTag ("a" ).text ();
2054+ } else { //Else must not be gc
2055+ fc = "none" ;
20622056 }
2063- } else if ( elements . size () == 3 ) {
2057+ } else {
20642058 fc = "none" ;
20652059 }
20662060 return fc ;
@@ -2076,32 +2070,19 @@ private static String getFreeCompanyFromPage(Document doc) {
20762070 private static int [] getLevelsFromPage (Document doc ) throws Exception {
20772071 //Initialize array list in which to store levels (in order displayed on lodestone)
20782072 ArrayList levels = new ArrayList ();
2079- //Get the html of the table for levels
2080- Elements table = doc .getElementsByClass ("class_list" ).select ("tr" );
2081- //I
2082-
2083- for (Element e : table ) { //For each row of table
2084- //Select the first level
2085- String lvlOne = e .select ("td:eq(1)" ).text ();
2086- //Initialize var to store second
2087- String lvlTwo = null ;
2088-
2089- if (e .select ("td" ).size () > 3 ) {
2090- //Second level
2091- lvlTwo = e .select ("td:eq(4)" ).text ();
2092- }
2093-
2094- if (lvlOne .equals ("-" )) {//If a dash
2095- levels .add (0 );
2096- } else {
2097- levels .add (Integer .parseInt (lvlOne ));
2098- }
2099-
2100- if (lvlTwo .equals ("-" )) {
2101- levels .add (0 );
2102- } else if (!lvlTwo .equals ("" )) {
2103- levels .add (Integer .parseInt (lvlTwo ));
2073+ Elements discipleBoxes = doc .getElementsByClass ("character__job" );
2074+
2075+ for (int i = 0 ; i < discipleBoxes .size (); i ++) {
2076+ Elements levelBoxes = discipleBoxes .get (i ).getElementsByClass ("character__job__level" );
2077+ for (Element levelBox : levelBoxes ) {
2078+ String strLvl = levelBox .text ();
2079+ if (strLvl .equals ("-" )) {
2080+ levels .add (0 );
2081+ } else {
2082+ levels .add (Integer .parseInt (strLvl ));
2083+ }
21042084 }
2085+ System .out .print (levelBoxes .size ());
21052086 }
21062087
21072088 //Initialize int array
@@ -2126,14 +2107,17 @@ private static int[] getLevelsFromPage(Document doc) throws Exception {
21262107 * @return the set of strings representing the player's minions.
21272108 */
21282109 private static ArrayList getMinionsFromPage (Document doc ) {
2129- //Get minion box element
2130- Element minionBox = doc .getElementsByClass ("minion_box" ).get (1 );
2131- //Get minions
2132- Elements minionSet = minionBox .getElementsByTag ("a" );
2110+
21332111 //Initialize array in which to store minions
21342112 ArrayList minions = new ArrayList ();
2135- for (int index = 0 ; index < minionSet .size (); index ++) { //For each minion link store into array
2136- minions .add (minionSet .get (index ).attr ("title" ));
2113+ //Get minion box element
2114+ Elements minionBoxes = doc .getElementsByClass ("character__minion" );
2115+ if (minionBoxes .size () > 0 ) {
2116+ //Get minions
2117+ Elements minionSet = minionBoxes .get (0 ).getElementsByTag ("li" );
2118+ for (int index = 0 ; index < minionSet .size (); index ++) { //For each minion link store into array
2119+ minions .add (minionSet .get (index ).getElementsByTag ("div" ).attr ("data-tooltip" ));
2120+ }
21372121 }
21382122 return minions ;
21392123 }
@@ -2146,14 +2130,18 @@ private static ArrayList getMinionsFromPage(Document doc) {
21462130 * @return the set of strings representing the player's mounts.
21472131 */
21482132 private static ArrayList getMountsFromPage (Document doc ) {
2149- //Get minion box element
2150- Element minionBox = doc .getElementsByClass ("minion_box" ).get (0 );
2151- //Get mounts
2152- Elements mountSet = minionBox .getElementsByTag ("a" );
2133+
21532134 //Initialize array in which to store minions
21542135 ArrayList mounts = new ArrayList ();
2155- for (int index = 0 ; index < mountSet .size (); index ++) { //For each mount link store into array
2156- mounts .add (mountSet .get (index ).attr ("title" ));
2136+
2137+ //Get minion box element
2138+ Elements minionBoxes = doc .getElementsByClass ("character__mounts" );
2139+ //Get mounts
2140+ if (minionBoxes .size () > 0 ) {
2141+ Elements mountSet = minionBoxes .get (0 ).getElementsByTag ("li" );
2142+ for (int index = 0 ; index < mountSet .size (); index ++) { //For each mount link store into array
2143+ mounts .add (mountSet .get (index ).getElementsByTag ("div" ).attr ("data-tooltip" ));
2144+ }
21572145 }
21582146 return mounts ;
21592147 }
@@ -2166,7 +2154,7 @@ private static ArrayList getMountsFromPage(Document doc) {
21662154 private static Date getDateLastUpdatedFromPage (Document doc , int id ) throws Exception {
21672155 Date dateLastModified = new Date ();
21682156 //Get character image URL.
2169- String imgUrl = doc .getElementsByClass ("bg_chara_264 " ).get (0 ).getElementsByTag ("img" ).get (0 ).attr ("src" );
2157+ String imgUrl = doc .getElementsByClass ("character__detail__image" ). get ( 0 ). getElementsByTag ( "a " ).get (0 ).getElementsByTag ("img" ).get (0 ).attr ("src" );
21702158 String strLastModifiedDate = "" ;
21712159
21722160 try {
0 commit comments