Solved

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

Posted on 2010-11-10
17
102 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
Comment Utility
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
Comment Utility
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
Comment Utility
hmm, wget should work just as well.  Try putting quotes around the URL ... other than that, I can't offer much more, sorry.
0
 

Author Comment

by:sakytech
Comment Utility
@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 51

Expert Comment

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

~bp
0
 

Author Comment

by:sakytech
Comment Utility
Thnx bill for replyin

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

Expert Comment

by:Bill Prew
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
I was thinking the same thing Bill ... I thought maybe quoting the url would resolve that.
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
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
Comment Utility
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 51

Expert Comment

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

~bp
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
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
Comment Utility

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 51

Expert Comment

by:Bill Prew
Comment Utility
==> sakytech

If this is solved can you accept and close?

~bp
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now