Saturday, September 3, 2011

Extract URLs from a downloaded web page

Computers > Programming > Windows Batch files

Download: parse_http.zip

How to use parse_http.exe

parse_http.exe is a command-line utility that will help you extract URLs from downloaded webpages.

It does that, by parsing a file using the " (double-quote) as a delimiter and print parsed phrases in different line.

E.g.
if a page contains
<a href="http://ulr.com/">Click me</a>

by running

:>\ parse_http.exe <filename>

it will print out:

<a href=
http://url.com/
>Click me</a>

By directing results to a file and then using (e.g. for http URLs)

find "http" <parsed filename>

you can extract urls from a file.

DateTime Stamps for filenames in Batch files

Computer > Programming > Batch Files


When working with MS-Windows batch file jobs, many times I need to create an output log file that will contain in its file name the specific date, time or both in its filename. In order to do this I need the filename in an environmental variable so I can fill in information using the '>>' redirectors after executing my batch commands.


I developed 3 batch files that do exactly that and here I share them with you.

Date_time_stamps.zip


date2file.cmd
Sets a date stamp to an environmental variable of your choice.

Usage:

c:>\date2file.cmd variable


Result: %variable% = YYYYMMDD


Example:
If today is 4/7/2010 then running


c:>\date2file.cmd mystamp


an environmental variable with name mystamp is created with value 20100704


time2file.cmd
Sets a time stamp to an environmental variable of your choice.

Usage:

c:>\time2file.cmd variable



Result: %variable% = hhmm


Example:
If it is run on 17:34 then  

c:>\time2file.cmd mystamp


an environmental variable with name mystamp is created with value 1734

dt2file.cmd
Sets a datetime stamp to an environmental variable of your choice.

Usage:

c:>\date2file.cmd variable



Result: %variable% = YYYYMMDDhhmm


Example:
If it is run on 4/7/2010 5:23 then running


c:>\dt2file.cmd mystamp


an environmental variable with name mystamp is created with value 201007040523