boxing / boxrec

Retrieve information from BoxRec and return it in JSON format
MIT License
109 stars 18 forks source link

Can't login with provided credentials #276

Closed FelixFreelancer closed 2 years ago

FelixFreelancer commented 2 years ago

I keep getting this error when I try to login to the boxrec API. It just keeps saying like this. RequestError: Error: connect ETIMEDOUT 37.187.156.219:443

I've attached my code.

const boxrec = require("boxrec").Boxrec;
(async function () {
    try {
        const cookieJar = await boxrec.login(BOXREC_USER, BOXREC_PASSWORD);
    } catch(e) {
        console.log("login failed",  e);
    }
})();

I am using the latest node version 16.14.2 Thanks in advance.

mikedidomizio commented 2 years ago

Maybe a firewall? Where is this code running, on your local machine or in the cloud?

Are you blocked by BoxRec if you visit the website?

FelixFreelancer commented 2 years ago

Thanks for your fast responding. No I am not blocked by Boxrec when I visit the website with the login information. And I am running the code on Windows VPS.

FelixFreelancer commented 2 years ago

Ah sorry. it seems they are blocking the VPS IP. Actually I was able to access to it on my local machine. Let me investigate it more.

mikedidomizio commented 2 years ago

Yeah, it's unfortunate but I believe they have a block list - I've found it also blocks AWS/GCP

mikedidomizio commented 2 years ago

If you do figure something out, please let me know

FelixFreelancer commented 2 years ago

Btw, I also tried it on my local machine. But I got this error. RequestError: Error: Client network socket disconnected before secure TLS connection was established

Could you please check this issue?

mikedidomizio commented 2 years ago

I just checked with boxrec@^7.2.1 and it's working. Are you running through a proxy or VPN?

these environment variables may be the culprit - HTTPS_PROXY, HTTP_PROXY.

This stackoverflow thread may be of some help.

FelixFreelancer commented 2 years ago

Thanks I fixed the issue after I adjusted my network settings.

Btw, Could you guide me once more in terms of data structure. For example, I got this response when I request this one as I want to get the schedules of tomorrow. await boxrec.getDate(cookieJar, "2022-04-06"); And it returns this weird data structure and not sure how to parse them. I checked the document but didn't find yet about that.


t {
  '$': [Function: initialize] {
    html: [Function: html],
    xml: [Function: xml],
    text: [Function: text],
    parseHTML: [Function: parseHTML],
    root: [Function: root],
    contains: [Function: contains],
    merge: [Function: merge],
    load: [Function: load],
    _root: Node {
      type: 'root',
      name: 'root',
      parent: null,
      prev: null,
      next: null,
      children: [Array],
      'x-mode': 'no-quirks'
    },
    _options: { xml: false, decodeEntities: true },
    fn: Cheerio { constructor: [Function: LoadedCheerio] }
  }
}

Thanks

mikedidomizio commented 2 years ago

Yeah, the documentation could use updating. There's a WIP from myself about how it all works.

So if you want all the information, you would do something like this

const dateResponse = await boxrec.getDate(cookieJar, "2022-04-06");
console.log(dateResponse.output)

otherwise you would just use the individual getters, which I'm a bit foggy remembering what they are. Someone would use the individual getters to faster parse whatever information they need, where using output does have to parse all the information.

Anyways, output is what you want at this time.

FelixFreelancer commented 2 years ago

Hi @mikedidomizio

Could you also please tell me how to get boutID (for example "726555/2037455") from the response of getDate function? await boxrec.getBoutById(cookieJar, "726555/2037455"); As you can see, we need to know the boutID to get an information of the bout.

Actually I want to get a bout info but not sure how to get the boutID by using the response of getDate function. await boxrec.getDate(cookieJar, "2022-04-08");

FelixFreelancer commented 2 years ago

Hi @mikedidomizio

I've been researching to get the boutID (for example "726555/2037455") so far. I already checked most of the functions listed on this package. But I didn't find the solution yet.

Could you please have a look at it when you are available? It would be very appreciated if you can find it for me.

Thanks

mikedidomizio commented 2 years ago

So a bunch of pages are just multiple tables of events/bouts so they're broken down into a hierarchy.

If I want the bout link from the first bout of the first event I would do

dateResults.events[0].bouts[0].links.bout

That should be what you're looking for I hope.

It's documented but the documentation is auto generated and doesn't really make it clear. Documentation could be improved.

FelixFreelancer commented 2 years ago

Thanks for your answer

I already checked the events[0].bouts[0].links.bout but it is always null no matter what event/bout is. The links always gives this object. {bio: null, bout: null, other: []} Could you please have a look at it again?

Thanks

mikedidomizio commented 2 years ago

It's possibly broken. I'll look at it when I can. No ETA on that. I'll let you know when I know something

FelixFreelancer commented 2 years ago

I am just wonder if you've had time to check the issue? If you are able this fix this issue, that would be very much appreciated.

Thanks

mikedidomizio commented 2 years ago

This should be fixed with boxrec@8.0.0

This is a breaking change and now date is not .getDate(2022-01-01), it is an object:

await boxrec.getDate(cookie, {
                day: 28,
                month: 9,
                year: 2019,
            })

This issue was automatically closed when the PR merged but let me know how it goes.

FelixFreelancer commented 2 years ago

Thanks a lot !