-1

Overview

My goal is to write a Bash script on WSL2 that pulls data from the Brave browser's home page and stores it in a text file. Specifically, I would like to access the value for 'Brave Rewards' seen in this picture and store it in a Bash variable:

Screenshot of brave://rewards/

Screenshot of brave: No URL

Issue

I can't figure out how to access this page programmatically. There's no URL that I can use to download it with wget or curl. All I can find is brave://rewards/, which doesn't work from curl or wget:

# ISSUE GETTING CONTENTS
content=$(wget brave://rewards/ -q -O -)
echo $content
# Blank line returned

The browser is the Windows version, which I can launch either from the shell on WSL2/Ubuntu (via xlaunch) or directly from Windows.

Is there any way that I can programmatically access the "Brave Rewards" value or the brave://rewards URL?

NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70
  • 1
    That's not a URL, it's a browser-internal page, isn't it? Like chrome:// is in Chrome. If so, then you can't access it from anything but the Brave browser itself. You could try to automate from within, but even that will not be easy (if possible at all). – Christian Fritz Oct 15 '21 at 03:38
  • I believe in Brave the newtab page url is `chrome://newtab` – jared_mamrot Oct 15 '21 at 04:13
  • Very odd to me that this was closed as "needs details". It seemed perfectly clear what the question was asking to me. That said, since I understood it and others apparently didn't feel it explained it well enough, I've provided an edited version for Reopen Votes. It feels like a reasonable, if naive (and there's nothing wrong with that), question to me. – NotTheDr01ds Oct 15 '21 at 22:16

1 Answers1

0

Unfortunately, this isn't something you'll be able to "scrape", as you seem to be trying. The brave://rewards page, as mentioned in the comments, is an internal browser page. You won't have access to this page from wget or any other software, regardless of whether it is WSL, pure Linux, etc.

The browser apparently communicates with api.rewards.brave.com to get this information, but as far as I can tell there is no documentation on that API.

There might be two possibilities for obtaining the information you want programmatically:

  • If you really want to "dig in", you can look at the source code (JavaScript and HTML) of brave://rewards from within the browser by starting the Developer tools (Ctrl+Shift+I). The main script is brave_rewards_page.bundle.js. It may be possible to reverse-engineer the script.

  • Perhaps a better option, depending on how often you would want to do this, is to attempt to script this via Python/Selenium/Chromedriver. Using this stack, you can "automate" the browser to open the brave://rewards page and access the contents of the <div> with the reward value.

    Some tips for doing this from WSL2:

    • You will need to use the Linux version of Brave. Selenium on WSL2 won't be able to connect to the Windows Brave's chromedriver.
    • That means that you'll also need the ability to run GUI apps on WSL2. This can be most easily done if you have the ability to upgrade to Windows 11 with WSLg support. Alternatively, I prefer xrdp personally for accessing GUI apps in WSL2 on Windows 10. See this question and a separate answer I provided here for more details.
NotTheDr01ds
  • 15,620
  • 5
  • 44
  • 70