43

I am searching for a text browser running JavaScript. It should be compatible with Linux platform.

Other features:

  • run JavaScript (this is the most important)
  • minor CSS rendering (text colors, background colors, borders maybe)
  • support XHR (is supposed to do if it runs js)
  • run in command line (terminal)

Any recommendations?

I tried lynx and elinks (sudo apt-get install ...), both not supporting JS.

3
  • 2
    Call me crazy, but I think links supports javascript.
    – dotVezz
    Sep 23, 2014 at 16:38
  • @dotVezz If you prove me that, I will give you 100 points. :smile: Add an answer with the instructions and I will review it. :-) Sep 23, 2014 at 16:54
  • 2
    I should have done some google-fu before I commented. Javascript support is not available by default. Both it and elinks have an --enable-javascript compile flag. By default, "JavaScript support was removed in release 2.1pre29 because it was buggy." So in other words... I probably wouldn't bother with links and elinks.
    – dotVezz
    Sep 23, 2014 at 19:47

5 Answers 5

14

// , Consider brow.sh, because of its low bandwidth but extremely flexible support for different kinds of web pages:

enter image description here
https://www.brow.sh

It also has a clever way of using True color support in terminals to render images, and supports modern replacements for SSH like MOSH.

Here are some demo pages:

html.brow.sh
Uses very basic graphics and HTML anchor tags. Although this service may appear similar to the terminal client it does not yet have feature parity.

text.brow.sh
Uses nothing but pure text, better for usage with curl, for instance.

For a demo of the browser, ssh brow.sh

You can also install it via docker pull:

docker pull browsh/browsh

Because brow.sh is Firefox under the hood, you can install Adblock and other extensions.

3
  • 1
    Since browsh requires a mouse for interacting with the document, I don't think it is very well suitable for terminal usage
    – phil294
    Apr 15, 2021 at 21:50
  • // , How are you sure about that? Apr 26, 2021 at 20:25
  • There is an open PR from 2018, but that's about it. github.com/browsh-org/browsh/issues
    – phil294
    Apr 27, 2021 at 1:46
10

Lynx does not support JavaScript, but Links does:

sudo apt-get install links

then to compile Links with JavaScript support, use the configure option --enable-javascript be aware that is buggy according to the documentation.

Best of luck

5
  • BTW, a text-based browser with JS support would be the best Christmas present to me. :-) Dec 17, 2014 at 9:46
  • Is this of any help? brandonhutchinson.com/JavaScript_support_with_links.html
    – user10405
    Dec 17, 2014 at 9:52
  • Tried it, I successfully compiled it but I don't see any difference. I opened an HTML file containing alert(1) but nothing is displayed. Jan 13, 2015 at 20:01
  • 1
    Even if you compile it with JavaScript, I think you have to separately enable it in the configuration. See links.twibright.com/user_en.html#ap-javascript
    – Brandin
    Dec 6, 2016 at 14:18
  • @IonicăBizău using alert is not the best test, because there's a difference between "running Javascript" and "showing alert boxes". It's better to test with document.write("hello world") to put the test text into the document itself, because quite a few browsers that are perfectly Javascript capable may be set to suppress alert boxes, so "yes we support Javascript but not alert boxes" is a reasonable position (so if you specifically want support for alert boxes then I'm afraid you have to say so☺) Jun 22, 2020 at 13:07
5

2017 solution:

Here's a solution for rendering html+js in the terminal:

Required:

  • Chrome 59 or greater
  • Using chrome in headless mode allows you to render a page with javascript through the terminal!
  • (it outputs raw html though)
  • Hermit
  • Simply renders raw html to readable text in the terminal!

Example Usage:

 $ google-chrome --headless --disable-gpu --dump-dom https://javatester.org/javascript.html | hermit


  $ chromium  --headless --disable-gpu --dump-dom https://javatester.org/javascript.html |html2text

Output:

...
Your web browser supports JavaScript version 1.7
...

It worked!

3
  • I tried it but got: IS WORKING JavaScript IS WORKING in your web browser JavaScript IS NOT WORKING in your web browser. Any idea what went wrong? Should I enable javascript in chrome (though only command line)? Thanks!
    – Matifou
    Mar 24, 2020 at 0:02
  • @Matifou that happened because the test page's "not working" text is in a <noscript>, Chrome does not remove noscript elements from its DOM output, and Hermit renders noscript because it doesn't expect the Javascript to have been executed. To hide <noscript> we'll need either (a) Hermit to be enhanced with a "remove noscript" option or (b) extra Javascript to somehow be injected into the page to remove noscript via DOM manipulation in Chrome or (c) add something else to the toolchain to remove noscript before Hermit sees it. (My Web Adjuster removes noscript if js_interpreter is set) Jun 22, 2020 at 12:54
  • Incidentally you can avoid installing Hermit by using lynx -stdin -dump -nolist instead of hermit, but either way you will get text from <noscript> included unless you somehow take it out. Jun 22, 2020 at 13:00
3

As of v0.23, Web Adjuster has a PhantomJS option, which can partially Javascript-enable any browser with the help of PhantomJS. I say "partially" because it's not (yet?) working with POST forms and Javascript-only links, but it's fine for reading the text of a page which requires Javascript before showing you that text.

sudo apt-get install python-selenium # or sudo yum install python-selenium
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-i686.tar.bz2
tar -jxvf phantomjs-2.1.1-linux-i686.tar.bz2 
cd phantomjs-2.1.1-linux-i686/
sudo mv bin/phantomjs /usr/local/bin/
cd ..
sudo apt-get install python-tornado # or sudo pip-install tornado
wget http://ssb22.user.srcf.net/adjuster/adjuster.py
python adjuster.py --js_interpreter=PhantomJS --real_proxy

and in another window or tab

http_proxy=http://localhost:28080 lynx http://site-that-needs-javascript.example.com/

Disclosure: Web Adjuster maintainer here.

4
  • I tried the solution proposed by @silas-s-brown. adjuster.py wants ` sudo apt install firefox-geckodriver python adjuster.py --js_interpreter=HeadlessFirefox --real_proxy ` I get the error messages: Web Adjuster v0.305 (c) 2012-20 Silas S. Brown Licensed under the Apache License, Version 2.0 Listening on port 28080 Starting 1 webdriver... done Jun 20, 2020 at 14:17
  • Daisukes's comment continued from above: [E 200620 10:15:28 adjuster:2427] Exception (<class 'selenium.common.exceptions.WebDriverException'>, 'Service phantomjs unexpectedly exited. Status code was: 127, adjuster line 2697'), adjuster line 2390 while renewing webdriver, retrying --- But I was able to use HeadlessFirefox and installed the firefox-geckodriver to get rid of the above error. Jun 21, 2020 at 12:09
  • @DaisukeAramaki Thank you for noting your experience. I recommend contacting Silas so they can troubleshoot with you. Jun 21, 2020 at 12:14
  • My answer is in need of an update: as @DaisukeAramaki found, more recent versions of Web Adjuster changed the old --PhantomJS option into --js_interpreter because there are now 3 to choose from (PhantomJS, HeadlessFirefox or HeadlessChrome). Since PhantomJS is no longer maintained, I now recommend using HeadlessFirefox or HeadlessChrome, and only using PhantomJS as a last resort if you're unable to install either of the others on the machine you're using. But for the record, I think phantomjs exit code 127 can mean it couldn't execute the binary (e.g. wrong architecture, or path issues). Jun 22, 2020 at 13:20
2

edbrowse

Non-pseudographical browser, ed-like interface.

Documentation: http://the-brannons.com/edbrowse/usersguide.html

Demo session:

$ edbrowse http://softwarerecs.stackexchange.com/
no ssl certificate file specified; secure connections cannot be verified
no trailing newline
74558
6590
# Let's print the beginning of the page
1,20p




{current community}

*
{chat}
{blog}
{Software Recommendations}
*
{Software Recommendations Meta}


your communities


{Sign up} or {log in} to customize your list.

{more stack exchange communities}
# Seach field is not here yet.
# Pressing "Enter" until we find it



{Stack Exchange}

{sign up}

{log in}

{tour}

{help}

* {Tour Start here for a quick overview of the site}

* {Help Center Detailed answers to any questions you might have}

* {Meta Discuss the workings and policies of this site}

 <> <Go implicit>




# Here it is. Let's find the line number
n
32 
28,32n
28 * {Help Center Detailed answers to any questions you might have}
29 * {Meta Discuss the workings and policies of this site}
30  <> <Go implicit>
31 
32 
30
 <> <Go implicit>
# We are now focused on the search field.
i=text browser
 <text browser> <Go implicit>
i*
submitting form
76944
10997
# OK, we have searched. Let's enumerate the results.
# First 30 lines are probably fluff, so begin with 40'th line
40,60p
* {Ask Question}



Search



<text browser>|<search>

127 results


{relevance}
{newest}
{votes}
{active}

10
votes
1answer
# Pressing Enter for more lines

{Q: Text based browser that runs JavaScript}

I am searching for a text browser running JavaScript.

It should be compatible with Linux platform. Other features:
# OK, we are here. Let's follow the link
n
63 It should be compatible with Linux platform. Other features:
58,62n
58 10
59 votes
60 1answer
61 {Q: Text based browser that runs JavaScript}
62 I am searching for a text browser running JavaScript.
61
{Q: Text based browser that runs JavaScript}
g
74946
7226
50,80p
{Text based browser that runs JavaScript}




up vote 10 down vote {favorite}
1

I am searching for a text browser running JavaScript.
It should be compatible with Linux platform.

Other features:
* run JavaScript (this is the most important)
* minor CSS rendering (text colors, background colors, borders maybe)
* support XHR (is supposed to do if it runs js)
* run in command line (terminal)

Any recommendations?

I tried lynx and elinks (sudo apt-get install ...), both not supporting JS.
{linux}
{open-source}
{web-browser}
{command-line}

{share}
{improve this question}
asked Sep 22 '14 at 18:02
{image}
{Ionic\u0103 Biz\u0103u}
3589



| 







2



Call me crazy, but I think {links} supports javascript.

- {dotVezz} Sep 23 '14 at 16:38





@dotVezz If you prove me that, I will give you 100 points. :smile:

Add an answer with the instructions and I will review it.

:-) - {Ionic\u0103 Biz\u0103u} Sep 23 '14 at 16:54





I should have done some google-fu before I commented.

Javascript support is not available by default.

Both it and elinks have an --enable-javascript compile flag.

By default, "{JavaScript support was removed in release 2.1pre29 because it

was buggy.}" So in other words... I probably wouldn't bother with links and elinks.

- {dotVezz} Sep 23 '14 at 19:47





add a comment




# Let's try to add a comment  
n
107 
100,107n 
100 By default, "{JavaScript support was removed in release 2.1pre29 because it
101 was buggy.}" So in other words... I probably wouldn't bother with links and elinks.
102 - {dotVezz} Sep 23 '14 at 19:47
103 
104 
105 add a comment
106 
107 
105
add a comment
# OK, enough for now.
# I don't know why "add a comment" is not shown as a link
q
2
  • +1 for edbrowse, I tried it some time ago, but I also would like a lynx-like interface. edbrowse is just text, from what I sow. Jan 21, 2015 at 16:26
  • Unfortunately edbrowse fails to support JS properly as well: github.com/CMB/edbrowse/issues/2
    – Vi.
    Jan 21, 2015 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.