Seeking lightweight headless browser for Mono/Mac/Xamarin with JavaScript support

I’m looking for a simple headless browser that works with Mono and Xamarin on Mac. I’ve tried a few options but they’re either not compatible or a pain to set up.

My main goal is to grab a single cookie from a website. The tricky part is that this cookie seems to be generated by JavaScript, so HttpClient can’t see it.

I don’t need anything fancy like taking screenshots or rendering pages. Just a basic tool that can run JavaScript and give me the cookies from a site.

I gave Awesomium a shot, but it didn’t play nice with Mono or Xamarin. Any suggestions for a lightweight alternative that’ll do the job? Thanks!

I’ve been in a similar situation, and Selenium WebDriver with the headless Chrome option worked wonders for me. It’s compatible with Mono and Xamarin on Mac, and setting it up isn’t too complicated. The best part is its robust JavaScript support, which sounds perfect for your cookie-grabbing needs.

To get started, you’ll need to install the Selenium.WebDriver and Selenium.WebDriver.ChromeDriver NuGet packages. Then, it’s just a matter of configuring the ChromeOptions for headless mode and initializing the driver.

One thing to watch out for: make sure you’re using the correct ChromeDriver version that matches your installed Chrome. This tripped me up at first, but once I sorted it out, it was smooth sailing.

Hope this helps! Let me know if you need any more details on the setup process.

CefSharp is definitely worth a try. It’s a lightweight Chromium-based browser that manages JavaScript execution effectively, which should help in extracting the cookie that’s generated dynamically. In my experience with Xamarin projects, setting it up for headless operation—using offscreen mode—is straightforward once you navigate the initial configuration. If CefSharp doesn’t fully meet your needs, PhantomJS might be an alternative, though it’s less maintained. Both have proven reliable for basic web scraping on Mono/Mac platforms.

hey, have u looked into puppeteer-sharp? it’s pretty good for headless browsing on mono/mac. it can handle javascript and grab cookies easy. might be overkill for just one cookie, but it’s not too hard to setup. worth checkin out if other options aren’t working for ya