Extracting select value

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
erikcw
Posts: 34
Joined: Sun Nov 13, 2005 5:08 pm

Extracting select value

Post by erikcw » Tue Nov 22, 2005 6:17 pm

Hi,

I'm trying to figure out how to extract the value from a drop down list.

The select list is organized:
<option value="1234">Item Name</option.
How can I choose the item from the list by name, and then extract the value (1234)?

Thanks!
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Tue Nov 22, 2005 11:15 pm

The feature to extract the value is high on our "to do" list. It will be available soon.

What you can already do with the current version is to select by index and then extract the text:

Code: Select all

VERSION BUILD=5010115     
TAB T=1     
TAB CLOSEALLOTHERS     
URL GOTO=http://www.iopus.com/iim/demo/v4/f2/automatic-data-entry.asp      
TAG POS=1 TYPE=SELECT FORM=NAME:WebDataEntry ATTR=NAME:COUNTRYID CONTENT=119 
EXTRACT POS=1 TYPE=TXT ATTR=<SELECT<SP>size=1<SP>name=COUNTRYID>*   
If you are already on our iOpus mailing list, you will be notified when the next release is available. If you are not on our mailing list, you can sign up so that you receive the notification. The sign-up form is available at

http://www.iOpus.com/newsletter

PS: There is an alternative that will always work: IIM offers you the option to return the HTML text of the complete page (or a certain part of it) and then parse the content manually in your script:

Code: Select all

VERSION BUILD=5010115     
TAB T=1     
TAB CLOSEALLOTHERS     
URL GOTO=http://www.iopus.com/iim/demo/v4/f2/automatic-data-entry.asp      
EXTRACT POS=1 TYPE=HTM ATTR=<TD<SP>vAlign=top<SP>align=left<SP>bgColor=#ffffff>*   
erikcw
Posts: 34
Joined: Sun Nov 13, 2005 5:08 pm

Post by erikcw » Tue Nov 22, 2005 11:26 pm

Tech Support wrote:The feature to extract the value is high on our "to do" list. It will be available soon.

What you can already do with the current version is to select by index and then extract the text:

Code: Select all

VERSION BUILD=5010115     
TAB T=1     
TAB CLOSEALLOTHERS     
URL GOTO=http://www.iopus.com/iim/demo/v4/f2/automatic-data-entry.asp      
TAG POS=1 TYPE=SELECT FORM=NAME:WebDataEntry ATTR=NAME:COUNTRYID CONTENT=119 
EXTRACT POS=1 TYPE=TXT ATTR=<SELECT<SP>size=1<SP>name=COUNTRYID>*   
If you are already on our iOpus mailing list, you will be notified when the next release is available. If you are not on our mailing list, you can sign up so that you receive the notification. The sign-up form is available at

http://www.iOpus.com/newsletter
But right now it is not possible to extract the value="119" (or the "CONTENT")?

Maybe you can help me with another way of solving this problem then.

I have a page that has a bunch of items listed in the left column, and in the right column there are links to edit/delete each item.

itemA | Edit/Del (links to edit.php?id=123)
item B | Edit/Delete (links to edit.php?id=456)
item C | Edit/Delete (links to edit.php?id=789)

I was going to extract the id from a select list on another page of the website, and then use URL GOTO edit?id={{EXTRACT}}

How can I find the item I want to edit on the page, and then click the correct link? All I have is the name of the item I want to edit.


Here is an example of the source code of the page. This is for ITEM A - there could be 100 table rows like this on the page...
<tr>
<td align="left" valign="middle" height="18" bgcolor="#ffffff">&nbsp;<b>ITEM A</b></td>
<td align="center" valign="middle" bgcolor="#ffffff">&nbsp;1</td>

<td align="center" valign="middle" bgcolor="#ffffff">&nbsp;25</td>
<td valign="middle" bgcolor="#ffffff" align="center">&nbsp;<a href="a.php?t=1242"><b>10</b></a></td>
<td align="center" valign="middle" bgcolor="#ffffff">&nbsp;<a href="m.php?n=targets&t=1242"><b>10</b></a></td>
<td align="center" valign="middle" bgcolor="#ffffff"><a href="edit.php?n=edit&t=1242">Edit</a>&nbsp;-&nbsp;<a href="ms.php?n=ms&t=1242">Del</a>&nbsp;-&nbsp;<a href="#" onClick="if(confirm('Are you sure you want to delete?')) document.location='ms.php?haction=del&t=1242'; return false;">Delete</a></td>
</tr>
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Wed Nov 23, 2005 12:11 am

You can extract the URL using Relative Extraction ( http://www.iopus.com/iim/help/extract_relative.htm ):

You extract the the URL of the first "Edit" command after the item you need (e. g. item B)

The following macro shows this principle. It extracts the download url if given the name of program:

Code: Select all

URL GOTO=http://www.iopus.com/download/     
TAG POS=1 TYPE=B ATTR=TXT:<SP>IIM<SP>Image<SP>Recognition<SP>Plugin<SP>(0.4<SP>MB)   
EXTRACT POS=R1 TYPE=HREF ATTR=<B>*   
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Wed Nov 23, 2005 12:16 am

You can then even use the extracted value to find the right EDIT command and click on it. To do this, record a TAG command using the "Link URL" clickmode and replace the URL with the {{!EXTRACT}} variable.

Here is the example based on our download website:

Code: Select all

URL GOTO=http://www.iopus.com/download/     
TAG POS=1 TYPE=B ATTR=TXT:<SP>IIM<SP>Image<SP>Recognition*
EXTRACT POS=R1 TYPE=HREF ATTR=<B>*   
TAG POS=1 TYPE=B ATTR=HREF:*{{!EXTRACT}}*
Note: The two "*" wildcard symbols around the {{!EXTRACT}} variable are added to account for possible spaces or incomplete (relative) urls. In this specific example they are not required.
erikcw
Posts: 34
Joined: Sun Nov 13, 2005 5:08 pm

Post by erikcw » Wed Nov 23, 2005 12:40 am

Got it working! Wow - you guys are good! Bravo!
Post Reply