LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-08-2005, 12:48 AM   #1
Itsu
Member
 
Registered: Jan 2004
Location: Gladstone, Oregon
Distribution: Gentoo 2005; FreeBSD 5.3
Posts: 32

Rep: Reputation: 15
Parsing HTML Source Code


I need a bit of help with shell scripting. I'm trying to find an easy way to parse html code from the command prompt. Ideally, I'd want a way just to echo the source code to the console, that way I could just grep it or use awk/sed.

To put things simply, I'm looking for the equivilant of:

cat http://www.google.com

Thanks in advance for any help.
 
Old 10-08-2005, 01:04 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
You mean something like this?
Code:
#!/bin/bash

# Pull the page in with wget
wget www.google.com -O /tmp/webpage_fetch.html

# Display the page's contents
cat /tmp/webpage_fetch.html

# Clean up by removing the page
rm /tmp/webpage_fetch.html
 
Old 10-08-2005, 01:20 AM   #3
Itsu
Member
 
Registered: Jan 2004
Location: Gladstone, Oregon
Distribution: Gentoo 2005; FreeBSD 5.3
Posts: 32

Original Poster
Rep: Reputation: 15
That'd do, thanks for your help! I also noticed you could do them same with lwp-mirror, which is part of libwww-perl, but it seems overkill to involve perl into something like this.

Last edited by Itsu; 10-08-2005 at 01:31 AM.
 
Old 10-08-2005, 01:34 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Actually, I did some more reading, and a script itself is overkill. You can accomplish the same thing with:
Code:
wget -q -O - www.google.com
Take it for a test drive and see...
 
Old 10-08-2005, 01:44 AM   #5
Itsu
Member
 
Registered: Jan 2004
Location: Gladstone, Oregon
Distribution: Gentoo 2005; FreeBSD 5.3
Posts: 32

Original Poster
Rep: Reputation: 15
Ahh, that's exactly what I was looking for. Thank you, much.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing out html with egrep binaryechoes Linux - Software 2 12-02-2005 11:49 PM
Parsing out html with egrep binaryechoes Linux - Newbie 3 12-02-2005 12:41 AM
HTML parsing library nodger Programming 1 09-01-2005 01:42 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
HTML parsing with HTML::TreeBuilder smaida Programming 0 07-10-2005 09:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration