Solved

How to write a Batch script to go to a webpage and save that page in .csv

Posted on 2010-11-10
17
106 Views
Last Modified: 2014-11-24
Hi
I am looking for script  which can save  a webpage in .csv.
This  particular page has text content.
What now i do is go to that intranet site   click save as name.csv...and convert it into a text file then send that to ETL team.
Is there a way i can automate this process untill converting it into txt file using a batch script?
any help is appreciated.
0
Comment
Question by:sakytech
  • 6
  • 5
  • 4
17 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 34107098
google and download a tool called  httpget.exe

then in your script you can do this:

httpget.exe  "http://server.com/webpage.ext"  >  result.csv
0
 

Author Comment

by:sakytech
ID: 34107192
Thanx for reply Knight,
But i can't download 3rd part tool on sys,
i tried wget.. but that doesn't work,it errors out.    I tried this ..[wget  -l 1 c:\test.csv http:// <URL>]... this does prety what i want to ..but it won't work for
my intranet url, it throws error 404. any insights?

any  suggestions??

Thanks,
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 34107202
hmm, wget should work just as well.  Try putting quotes around the URL ... other than that, I can't offer much more, sorry.
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

Author Comment

by:sakytech
ID: 34107253
@knight ..well i tried that..it won't work, batch script does nothing. so i tried from command prompt
which gives the error. does it have anything to do with webpage, this site is accesable  only within company's network.

anyway thanks for trying ,
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34108641
Are you running this command on a computer inside the company, or outside the company?

~bp
0
 

Author Comment

by:sakytech
ID: 34108999
Thnx bill for replyin

inside the company..just trying to automate the process
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34111482
Do you have any special characters in the URL string you are trying to invoke, like >, <, &, ^, or | perhaps.  Those can cause problems since they are special characters to the command shell.

~bp
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 34111580
I was thinking the same thing Bill ... I thought maybe quoting the url would resolve that.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34111630
Agreed knight, often quoting works in general, I haven't done a lot with wget so wasn't sure.  And without seeing the specific URL it's hard to propose a lot of thoughts on what might be causing a problem.

sakytech is it possible for you to share the full command line exactly as you are executing it?  Since the site is internal to your network I don't think sharing the URL would be a security risk, but that's best for you to decide.

Also, if you just do the following, does that open the page in your default browser?

START "http:\\yoururl.html"

~bp
0
 

Author Comment

by:sakytech
ID: 34114539
thanks for the response,
this is the link looks like this http://icwebprod.wv.xyz.com/scripts/saky/

yea it works just fine when  i do start "http://icwebprod.wv.xyz.com/scripts/saky ".
as you mentioned placing the quotes worked in command prompt, but not in  batch script
[@echo off
cls
wget  "http://icwebprod.wv.xyz.com/scripts/saky" ]  am i missing something??
and also..conversion to .csv and to .txt! i have no clue how to do that ..in script!
any one know how to?


Thanx, bill.knight





yeaa bill,  when i  do start "http://icwebprod.wv.xyz.com/scripts/saky/
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 34114835
wget / httpget will create the file in the source format ... so if you wget a .jpg file it will create a .jpg file, if you wget a text file it will create a text file (by any name or extension you give it, e.g.  .txt or .csv or whatever).   In other words, wget will not "convert" from one format to another for you -- it all depends on what is returned from the specified URL.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34116263
Have you tried adding the -d option to the command line, which should provide some additional debugging info from wget.

~bp
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34116329
Have you tried adding the -d option to the command line, which should provide some additional debugging info from wget.

I also just noticed one other thing.  You stated that this was your command line:

wget  -l 1 c:\test.csv http://icwebprod.wv.xyz.com/scripts/saky/

but that isn't correct syntax.  It needs to be:

wget  -l 1 -O c:\test.csv http://icwebprod.wv.xyz.com/scripts/saky/

I tried this from both the command line and in a BAT file and both worked fine here.

~bp
0
 

Author Comment

by:sakytech
ID: 34138720

Yea bill, sorry was caught up with different work.. it works just fine.. i missed that syntax..!!

Thanks for the help! It is solved!
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 34539938
==> sakytech

If this is solved can you accept and close?

~bp
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question