Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes, Jobs, DoL, DoH, Eureka and Bozja levels are always null #7

Open
Tancred423 opened this issue Nov 28, 2021 · 2 comments
Open

Comments

@Tancred423
Copy link

Situation

The result of a character request by ID always shows classes, etc. as null. I found the issue and made a fix, but I rather not make a pull request as this is a very dirty fix. I will still explain what I did and what caused the issue in case you want to fix it.

This is the result currently:
image

Explaining the problem

In the page-parser.ts only the DOM from the character profile will be requested, so /lodestone/character/:id. But not from the Class/Job overview, so /lodestone/character/:id/class_job. That is the one we need in order to apply the css query selectors for the classes.

My (dirty) fix for that

What i just did now is, I added another DOM request at the start of the parse() function that is very similar to the existing one, but for the /class_job path:

const classJobDataAll = await axios.get(`${this.getURL(req)}/class_job`).catch((err: any) => {
   throw new Error(err.response.status)
})

const classJobData = classJobDataAll.data
const classJobDom = new JSDOM(classJobData)
let classJobDocument = classJobDom.window.document

Now we have document for all the general info and classJobDocument for the classes.

Then later, when we call this.handleColumn() in currently line 54, we have to pass in the classJobDocument instead of document if the column is one of the classes.

For that (and this is the very dirty part), I just made a simple array with all classes and checked the column:

let correctDocument = document
if (
   ['Bozja', 'Eureka', 'Paladin', 'Warrior', 'Darkknight', 'Gunbreaker', 'Monk', 'Dragoon', 'Ninja', 'Samurai', 'Whitemage', 'Scholar', 'Astrologian', 'Bard', 'Machinist', 'Dancer', 'Blackmage', 'Summoner', 'Redmage', 'Bluemage', 'Carpenter', 'Blacksmith', 'Armorer', 'Goldsmith', 'Leatherworker', 'Weaver', 'Alchemist', 'Culinarian', 'Miner', 'Botanist', 'Fisher']
      .includes(column)
) {
   correctDocument = classJobDocument
} else correctDocument = document

Now we just have to pass correctDocument to this.handleColumn() instead of document and it will work again.

And this is the result with the same character after the fix:
image
(Eureka is in fact null, because I never played that, but I saw the Eureka info on a friends char!)

@Supamiu
Copy link
Contributor

Supamiu commented Nov 28, 2021

This looks like a duplicate of xivapi/lodestone-css-selectors#12

@nazdir
Copy link

nazdir commented Feb 28, 2022

I don't think this is a duplicate of the other issue. Parsing with Nodestone returns null for all classes. The other issue was only related to Eureka/Bozja.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants