pikax / swgoh

Unofficial node library for swgoh.gg
MIT License
17 stars 4 forks source link

swgoh.profile should return also the profile's character name #12

Closed munelear closed 6 years ago

munelear commented 6 years ago

Please enhance the profile API to parse out the profile's character name and return it

https://github.com/pikax/swgoh/blob/04abb463e3cb8ae4f3fe8f020e1ec9f1df512a1e/src/parser/user.ts#L89

It is currently populating username with the swgoh.gg user name which is in the top panel. firefox reports the css selector and xpath currently being used to populate the username as follows: h5.panel-title:nth-child(2) > a:nth-child(1) /html/body/div[3]/div[2]/div[1]/div[1]/div[2]/h5/a

The character name for the profile can be found in the second panel which has identical markup. firefox reports the css selector and xpath for this character name as follows: h5.panel-title:nth-child(1) > a:nth-child(1) /html/body/div[3]/div[2]/div[1]/div[4]/div/div/h5/a

pikax commented 6 years ago

Please enhance the profile API to parse out the profile's character name and return it It seems to be parsing the username https://runkit.com/embed/924o949xxh5k

Is there any difference between?

h5.panel-title:nth-child(2) > a:nth-child(1)

and

h5.panel-title:nth-child(1) > a:nth-child(1)

if so can you please provide an link with different username?

munelear commented 6 years ago

Here's an example profile https://swgoh.gg/u/xajx/

The library returns the swgoh.gg username (xAJx) from the top section. The in game name is in the bottom section labeled as "Player info", for this profile it should be just "AJ".

The html structure of these two panels looks identical and there doesn't really seem to be a way to distinguish them to select one or the other specifically using an element type, id, or class (that I can tell).

pikax commented 6 years ago

I will add playername to profile and username will still be swgoh.gg username

munelear commented 6 years ago

Thanks- returning both sounds good and is what I had intended to word the enhancement request to ask for.