Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to scrape some content from a webpage, so I can convert it into csv format; however, this page has a bunch of tables, and table (cells, rows), so I think instead of working with the source code of the page, it will be better to work with the content. And that's why I'm using lynx -dump. Ok so, there's a portion of the page that contains a list, and every row begins with a numbrer.
Code:
1 2/20/15 0 10 john tampa, fl
2 3/15/15 1 3 mike atlanta, ga
3...
4..
N..
how can I put every field in a csv file? I was thinking something along the lines
Code:
lynx -dump http://siteaddress.com/stats | "and some other pipes here"
Hi
Just dump the page and use blank/space as delimiter when you upload it into *office?
actually, what I did was to save the page to desktop as html, and them opening it, in excel and import it. it worked great, but I bash scripting was how I originally wanted to do it, but I fond it quiet cumbersome, but I was still curious as how I could do it.
Ok, easy - just search in Internet about replacing a char (space/blank in your case) with "sed" or "awk".
Example for such a search: "bash sed replace char"
Ok, easy - just search in Internet about replacing a char (space/blank in your case) with "sed" or "awk".
Example for such a search: "bash sed replace char"
ohh, I forgot to mentioned that there are a bounch of text before the lines I want to scrap from webpage. How would jump those lines? and start getting input from the ones I have?
^ with the limited information op provides i'll assume that lines that begin with a number are the ones that they are interested in:
Code:
grep ^[0-9] mia-tech.html | ...
ok, I'm still trying to figure this out. I save the dump from lynx to a text file, but for some reason the grep command doesn't work, and my guess is that it is b/c the page doesn't start with a number but with a space. lynx out put page a bit wierd. So the output really looks like this
Code:
1 1/1/2014 Unknown 2 2 Norfolk, VA
^[14][1] ^[15][2]
2 1/3/2014 Unknown 1 3 New York (Queens), NY
^[16][3] ^[17][4]
3 1/4/2014 Leonard Frank Harris Jr 2 2 Rock Falls, IL
^[18][5] ^[19][6] ^[20][7]
4 1/5/2014 Unknown 1 3 Erie, OH
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.