Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-09-2008, 02:39 AM
|
#1
|
|
Member
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176
Rep:
|
Automating database web search
I run weekly reports on an online database (I don't have full access to the database) where I need to generate states based on a certain field. Currently the only way to do this is to select each option from a drop down list, perform the search and copy the number I need from the search results. I then hit back, select the next option from the drop down list and repeat.
Quite tedious and time consuming. The database maintainers won't add the search option I need.
I was thinking that if I could see what query is being sent, I could then write a script that automatically sends the query, picks out the string I need from the result and save that.
What I need therefore is: - Ability to log into the site
- Create query
- Strip info I need out of result
- Save result
- Rinse and repeat
Any suggestions /help would be appreciated!
|
|
|
|
04-09-2008, 03:00 AM
|
#2
|
|
Member
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569
Rep:
|
It all depends on the interface to the database. If the web-address that displays the search results contains the search parameters - e.g. in the way a google search does - then you can copy this address and use "wget" to repeat that search from the command line or a script.
wget can be instructed to save the results to a file and you can then use grep/sed/whatever to interrogate the search results (which is now an HTML file on your disk) for the data you need.
If you need to login to the database, wget can do this too.
|
|
|
|
04-09-2008, 03:22 AM
|
#3
|
|
Member
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176
Original Poster
Rep:
|
Quote:
Originally Posted by blacky_5251
It all depends on the interface to the database. If the web-address that displays the search results contains the search parameters - e.g. in the way a google search does - then you can copy this address and use "wget" to repeat that search from the command line or a script.
wget can be instructed to save the results to a file and you can then use grep/sed/whatever to interrogate the search results (which is now an HTML file on your disk) for the data you need.
If you need to login to the database, wget can do this too.
|
No, that's the problem, I opened the frame that the search is being performed in to see what the web-address is and all it gives is:
Code:
www.some.site/admin_customers.asp?mode=search&ID=
No matter what search is being performed.
|
|
|
|
04-09-2008, 03:25 AM
|
#4
|
|
Member
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569
Rep:
|
Can you get an address by holding the mouse over the "search" button?
|
|
|
|
04-09-2008, 03:30 AM
|
#5
|
|
Member
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176
Original Poster
Rep:
|
Quote:
Originally Posted by blacky_5251
Can you get an address by holding the mouse over the "search" button?
|
No, it just gives the address posted above. I'm looking at the page source and it seems the variables are hidden:
Code:
<form action="admin_customers.asp?mode=search&ID="
method="post" id="searchForm" name="searchForm" onsubmit="return validateForm()">
<input type="hidden" id="mode" name="mode" value="search">
<input type="hidden" id="ID" name="ID" value="">
<input type="hidden" id="startpos" name="startpos" value="">
<input type="hidden" id="sort" name="sort" value="">
<input type="hidden" id="sortorder" name="sortorder" value="">
<input type="hidden" id="checkedItems" name="checkedItems">
<input type="hidden" id="uncheckedItems" name="uncheckedItems">
<input type="hidden" id="selectAll" name="selectAll">
<input type="hidden" id="deSelectAll" name="deSelectAll">
<input type="hidden" id="recordselected" name="recordselected">
<input type="hidden" id="resultsPerPage" name="resultsPerPage">
<input type="hidden" id="candidateActivity" name="candidateActivity">
<input type="hidden" id="queryID" name="queryID">
<input type="hidden" id="AdminQueryID" name="AdminQueryID" value="" />
<input type="hidden" id="AdminQueryName" name="AdminQueryName" value="" />
|
|
|
|
04-09-2008, 03:44 AM
|
#6
|
|
Member
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569
Rep:
|
All I can suggest is that you try to "guess" the address by creating the URL yourself using info from the hidden fields you found. Assign them values, separate them properly, and see how you get on.
|
|
|
|
04-09-2008, 06:17 AM
|
#7
|
|
Member
Registered: Aug 2004
Location: JHB - South Africa
Distribution: Kubuntu 7.04; openSUSE 10.1
Posts: 176
Original Poster
Rep:
|
Quote:
Originally Posted by blacky_5251
All I can suggest is that you try to "guess" the address by creating the URL yourself using info from the hidden fields you found. Assign them values, separate them properly, and see how you get on.
|
I've found an easier way to go about it. I'm using iMacros for Firefox, so now I can automate the process.
What I'm doing at the moment is letting the script run and writing down the numbers I need on each page (only one number, so not too bad), but what I'd like to do is save each page using:
Code:
SAVEAS TYPE=MHT FOLDER=* FILE=EasternCape
But then the file with the info I need is saved in the EasternCape_files folder. What I would need to do is write a script to descend into that folder, grep the portion of the file I need and dump the info into a text file so it has
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:44 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|