Using a While Loop and extracting Data

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
siteassessor
Posts: 1
Joined: Sun Jan 11, 2009 7:55 pm

Using a While Loop and extracting Data

Post by siteassessor » Sun Jan 11, 2009 8:10 pm

Hi all, as a newbie I have a quick question that you might be able to answer. As you can see from the code I have created a macro. I need to run the macro 40 times and extract the list of results and place in a txt file.

VERSION BUILD=6111213 RECORDER=FX
TAB T=1
URL GOTO=http://www.seventhsanctum.com/generate. ... =quickname
TAG POS=1 TYPE=SELECT FORM=NAME:frmControls ATTR=NAME:selGenCount CONTENT=%50
TAG POS=1 TYPE=SELECT FORM=NAME:frmControls ATTR=NAME:selGenType CONTENT=%MNAME
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:frmControls ATTR=NAME:subGenerate&&VALUE:Generate

Can some one steer me in the right direction as I know I'm just missing something simple.

thanks in advance

Tim
dharmendra2000
Posts: 214
Joined: Fri Jul 04, 2008 1:28 pm
Location: Ahmedabad
Contact:

Re: Using a While Loop and extracting Data

Post by dharmendra2000 » Mon Jan 12, 2009 6:08 am

If you want to run the same macro 40 times, there is no need to go for while loop.
Instead of clicking "Play" button, Enter 40 in "Max" text box and Click on "Play Loop" button.

Hope it will solve your purpose!!
Komak57
Posts: 9
Joined: Sat Jan 10, 2009 10:40 pm

Re: Using a While Loop and extracting Data

Post by Komak57 » Mon Jan 12, 2009 6:32 am

The issue you're running into is that the list generated is all 1 item. Extracting it is of little use, and because there aren't any clear makers between names, it makes it difficult to run Javascript to rip the text. I'm pretty experienced in text modifications and i cant find a quick and painless way to do this. Best suggestion is to chose another location to rip names from, or pull the generator source.

The generator location is http://www.seventhsanctum.com/generate.php
Accessing it directly is impossible.

Macro Script

Code: Select all

VERSION BUILD=6111213 RECORDER=FX

TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:frmControls ATTR=NAME:subGenerate&&VALUE:Generate
TAG POS=11 TYPE=DIV ATTR=TXT:* EXTRACT=TXT
TAB T=2
TAG POS=1 TYPE=TEXTAREA FORM=NAME:NoFormName ATTR=NAME:full CONTENT={{!EXTRACT}}
TAB T=1
HTML

Code: Select all

<head>
<title>iMacros Data Ripper ~Komak57</title>

<script type="text/javascript">
function IsUpperCase(var Check)
{
  if(Check == Check.toUpperCase()) return true;
  return false;
}

function Rip()
{
  var Line=document.getElementByName("full").value;
  var OnSecond=false;

for(var i = 0; i <= Line.length; location++) {
  var start = i;var end = i+1;
  var curChar=Line.substring(i,i+1);
  if (curChar != " ") {
    if (IsUpperCase(curChar)) {
      if (OnSecond==false) {
        alert("Name ["+nextName+"]");
        document.getElementById("Organized Names").value=nextName;
        nextName="";
        OnSecond=true;
      } else {
        OnSecond=false;
      }
      var nextName=nextName+curChar;
    }
  }
}

}
</script>

</head>


<body>
<form method="post" action="">
<textarea name="full" cols="40" rows="50">Names Here</textarea><br>
<textarea name="sorted" cols="40" rows="50" id="Organized Names">Output</textarea><br>
<input type="button" value="merge" onClick="Rip()">
</form>
</body>
This code has not been tested, or debugged, but you might find what your looking for with some simple edits.

Basic Method idea- there are 2 capitol letters per name. Look for the First Capitol Letter of each name, and save everything up until then as a Name.

Ex: Albert EinsteinIsaac Newton would continue until 'Einsteinsaac' and save [Albert Eindsting]Isaac to a document object named 'Organised Names'.

This may rip names, but it wont organize them properly, the output will pretty much be the same as the incoming text. Find a method to 'continue' text on a new line and you'll be good to go.
Post Reply