rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.7k stars 122 forks source link

Returned empty hash #299

Closed dunaevv closed 1 year ago

dunaevv commented 1 year ago
browser = Ferrum::Browser.new(
    headless: false,
    ignore_default_browser_options: true,
)
browser.go_to("https://betway.com/sports/live")

p browser.evaluate <<~JS
  (async () => {
    const object = {"BrowserId":3,"BrowserVersion":"106.0.0.0","BrandId":3,"ClientIntegratorId":1,"ClientTypeId":2,"JurisdictionId":2,"LanguageId":1,"TerritoryId":165,"SportsOrderingAreaId":3,"CategoryCName":"tennis","GroupLimit":1000,"CorrelationId":"b593f4d9-2d3a-4aeb-90ad-6a7f0ce71411"};
    const response = await fetch('https://sportsapi.betway.com/api/Events/V2/GetTopGroups', {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(object)
    })
    .then(response => response.json())
    .catch(error => console.warn(error));

    return response
  })
JS

When I used this evaluate example with playwright, I have JSON result Whats wrong with Ferrum, I dont know

route commented 1 year ago

Shouldn't you use evaluate_async or evaluate_func since it's async function? I don't see you calling the function at the first glance

dunaevv commented 1 year ago

Shouldn't you use evaluate_async or evaluate_func since it's async function? I don't see you calling the function at the first glance

oh, sry, I didnt know about evaluate_async, will try, thx!

route commented 1 year ago

I'll close for now. If something doesn't work you can reopen, or open new issue.