Extracting select value

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Extracting select value

by erikcw on Tue Nov 22, 2005 11:17 am

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!
erikcw
 
Posts: 34
Joined: Sun Nov 13, 2005 10:08 am

by Tech Support on Tue Nov 22, 2005 4: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>*   
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

by erikcw on Tue Nov 22, 2005 4: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>
erikcw
 
Posts: 34
Joined: Sun Nov 13, 2005 10:08 am

by Tech Support on Tue Nov 22, 2005 5:11 pm

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: 5003
Joined: Tue Sep 20, 2005 12:25 pm

by Tech Support on Tue Nov 22, 2005 5:16 pm

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.
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

by erikcw on Tue Nov 22, 2005 5:40 pm

Got it working! Wow - you guys are good! Bravo!
erikcw
 
Posts: 34
Joined: Sun Nov 13, 2005 10:08 am


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 4 guests

-->