The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20130305

sahi - automated web data extraction, export to tab separated csv file, in linux

here's a simple web data extraction script that logs into mywebsite.com, navigates to a user profile page, extracts the input text field values for "first name" and "last name", saves the values in a tab separated csv file, then logs out of mywebsite.com:

########test_write_to_file.sah###############

// start URL: http://mywebsite.com/login.jsf

_setValue(_textbox("username"), "myusername");
 

_setValue(_password("password"), "mypassword");
 

_click(_button("log in"));
_click(_link("User profile"));

var $ar = new Array();
 

$ar[0] = [_getText(_textbox("firstname")), _getText(_textbox("lastname"))];
 

_writeCSVFile($ar, "/home/me/userprofile.csv", true, "\t");
 

_click(_link("log out"));

########################################


start URL is a comment showing what you manually paste into the sahi controller > playback > start url field

see also part 2 of this tutorial:
sahi - automated web form submit using values from tab separated csv file, in linux

No comments:

Post a Comment