# Web-page in Text-console.



## valsorym (Jul 26, 2011)

Hi all,
Give me, 
How I be see the contents of web-pages in the console? Do not use the GUI.
At least the HTML code.

Example: 

```
# cat www.freebsd.org
```

It is must be my console:

```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The FreeBSD Project</title>
....
....
</div>
</body>
</html>
```

What can I be used in lieu of the command "cat"?


----------



## jrm@ (Jul 26, 2011)

There are text-based web browsers in ports such as www/lynx.


----------



## SirDice (Jul 26, 2011)

Install www/p5-libwww:

`$ GET [url]http://www.freebsd.org[/url]`

Or, if you don't want to install anything, use nc(1) aka "netcat"


```
$ nc www.freebsd.org 80
GET / HTTP/1.1
Host: www.freebsd.org
```


----------



## valsorym (Jul 26, 2011)

www/lynx.
- I'm surprised - it's a text browser. Super.

nc
- Do not work, why? - I will read books.


```
# GET [url]http://www.freebsd.org[/url]
```
- Worked! Thank you.

Thank all very much.


----------



## wblock@ (Jul 26, 2011)

doorways said:
			
		

> How I be see the contents of web-pages in the console? Do not use the GUI.
> At least the HTML code.



What is the application?  Is this homework?


----------



## valsorym (Jul 26, 2011)

> Originally Posted by *wblock*.
> What is the application? Is this homework?



No. 
I learn FreeBSD for themselves. I recently removed Windows XP. 
I like the idea of working in the console - no windows (GUI).
I loved the editor "vi". 


View HTML code of pages I need - I have been doing web-programming (my tools: Apache 2.0 + mod_wsg 3.3 + Python 3.2 in Win Xp).
On this occasion, talk in the section "Development / Userland Programming & Scripting". -  If I can not do it yourself.

Thank you all, again.


----------



## pbd (Jul 26, 2011)

Also ftp/curl is very useful tool and www/elinks is another good text-based browser.


----------



## wblock@ (Jul 26, 2011)

`% fetch -o - [url]http://www.freebsd.org[/url] | less`


----------



## valsorym (Jul 26, 2011)

Use "elinks" much more complicated than "lynx" - but the program stronger.
It's not about "GET", "curl" and "fetch". The beauty of "less".

```
# man less
```

"less" - easily view the contents (hjkl - navigator).
Ok. Thank all very much.


----------



## SirDice (Jul 27, 2011)

doorways said:
			
		

> nc
> - Do not work, why? - I will read books.


After you have made a connection with a webserver you will have to type in this:

```
GET / HTTP/1.1
Host: www.freebsd.org
```
Followed by an empty line. This is a simple, standard HTTP 1.1 request. It's what a browser does to get to the webpage. Netcat is just a really simple connection tool but it has many interesting uses


----------



## jrm@ (Jul 27, 2011)

If you are really set on only using the console there are some text-based browsers that can display images.  Definitely www/w3m can and there are a few others.  http://www.freebsd.org/ports is a web interface to ports. 

I can relate to wanting to keep things simple, but the browsing experience you will get with a text-based browser will be quite different than what most page developers intend.  You could try x11/xorg with a light window manager (http://forums.freebsd.org/showthread.php?t=21319) and a light browser (http://forums.freebsd.org/showthread.php?t=25331).  You could still use your favourite tools (vi/vim) from within Xorg.  But, maybe you've already tried this and have your reasons for sticking to the console. 

I apologize if some of these straightforward concepts are already clear to you; it's difficult to gauge someone's experience level.  I mention them because you said you are coming from XP and perhaps are new to unix-like operating systems like FreeBSD.

Good luck!


----------



## jrm@ (Jul 27, 2011)

SirDice said:
			
		

> After you have made a connection with a webserver you will have to type in this:
> 
> ```
> GET / HTTP/1.1
> ...



For some reason, some sites, including http://www.freebsd.org, don't reply with the page.  Substitute telnet for nc and it works fine.


----------



## valsorym (Jul 27, 2011)

For SirDice:

Sorry, I did not realize that it was necessary to introduce it:


```
# nc www.freebsd.org 80
GET / HTTP/1.1
```

I thought that the second line is part of the response from the server.
While I know that this HTTP request.
Thank you. (for persistence).



For mingrone:

Actually display a full page (images, background, js, flash) - little interest to me. 
For all this, I put the GNOME and FireFox.
Extract from the file /etc/rc.conf

```
â€¦
# GUI.
hald_enable=â€YESâ€
dbus_enable=â€YESâ€

gdm_lang=â€ru_RU.KOI8-Râ€
#gnome_enable=â€YESâ€
# end GUI sector.
â€¦
```

If I want to relax, I run GNOME:

```
# /usr/local/etc/rc.d/gdm forcestart
```

But:

```
# whereis w3m
/usr/ports/japanese/w3m

# cd /usr/ports/japanese/w3m
make && make install clean

# w3m  http://www.freebsd.org
```
Very well browser. Thanks.
In my opinion. He combined in himself as a highlight links "lynx" and power "elinks".



> Originally Posted by *mingrone*.
> I apologize if some of these straightforward concepts are already clear to you; it's difficult to gauge someone's experience level. I mention them because you said you are coming from XP and perhaps are new to unix-like operating systems like FreeBSD.
> 
> Good luck!



- no, no. I do not know much FreeBSD. Thanks for the details.

----------------------------------------------------------------------------------------------------------------------------------
Thank you all. I learned what I needed.


----------



## UNIXgod (Jul 27, 2011)

The reason to use a text based browser is that some machines you can't allow x11 on and some of the programs like links or lynx may be scriptable which should help in some edge case administration or data mining. I'm digging all the stuff with REST( Representational State Transfer) with nc(). Definitely going to experiment myself to see that.


----------



## valsorym (Jul 27, 2011)

Ok. Interesting thought. Thank you.


----------



## valsorym (Jul 27, 2011)

Thank you all very much! Theme maybe closed. 
Thank all, again.


----------

