How can I input random username using iMacros? I wanna create a simple sign up bot that will use random username every time. Any suggestion please.
I use 2 methods for this:
1) Purely random strings for one time use only.
Use this line to generate a string where in this case i<6 means the length of the output string and * 25 means the length of the array of letters to choose from
SET !VAR1 EVAL("var letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','x','y','z']; var string = ''; for(var i = 0; i < 6; i++){string += letters[parseInt(Math.random() * 25)]}; string")
to use the string add {{!VAR1}} where you need the username like so:
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:createaccount ATTR=ID:FirstName CONTENT={{!VAR1}}
2) Use pre-generated strings from a text file (Can be generated manually or by a 'random name generator' online), this allows you to save credentials for future use.
Generate a file.csv where each line holds comma seperated info for one user. Info is accessed as {{!COL1}} for first item, 2 for second item etc'
SET !DATASOURCE C:\Temp\stackoverflow.csv
'where to start in the csv file
SET !LOOP 1337
SET !DATASOURCE_LINE {{!LOOP}}
EVENTS TYPE=KEYPRESS SELECTOR="#new_post>DIV>P>DIV>DIV" CHARS={{!COL1}}
EVENTS TYPE=KEYPRESS SELECTOR="#new_post>DIV>P>DIV>DIV" CHARS={{!COL2}}
stackoverflow.csv file example:
pika,chuu,easypassword123
wobbu,ffet,mypassword
chari,zard,123456
I hope this helped, this is also my first comment ever.
Related
need help for extract text1,text2,text3 (i mean all text, sometimes until text9 in category)
<h4>Category:</h4>
<p>text1, text2, text3</p>
my imacros code just only extract text1
TAG POS=R1 TYPE=A ATTR=TXT:* EXTRACT=TXT
Q : how extract all text in category ?
Thanks
To expand on the JavaScript comment, this is how you could go about it:
ExtractCategory.js content
// Play the macro reading the category data
iimPlay("foo.iim");
// Get the last extracted value, i.e. the p content
var pContent = iimGetExtract();
// Parse the p using regex, first find a tag pairs and then drop the surrounding a tags
var result = pContent.match(/<a(.*?)<\/a>/g).map(function(val){
return val.replace(/<\/?a>/g,'').replace(/<a.+>/g,'');
});
// Pass the generated String to another macro to work with it
iimSet("passed_var", result);
iimPlay("bar.iim");
Next to ExtractCategory.js, foo.iim content
'Your previous code here, line #2 is just to find the right p in line #3 in a mockup html
TAG POS=1 TYPE=H4 ATTR=*
TAG POS=R1 TYPE=P ATTR=* EXTRACT=HTM
Next to ExtractCategory.js, bar.iim content
'Do whatever with the passed variable containing your formatted String
'This is just an output to show it
PROMPT {{passed_var}}
When you run ExtractCategory.js it will run your foo.iim code to extract the p content, parse it with regex (might want to be careful here, depending on what texts you are expecting this might break) and then pass the generated String on to another macro to do with it what you please.
Running this your result is text1,text2,text3 as desired.
Read up on http://wiki.imacros.net/iimSet() and http://wiki.imacros.net/iimPlay() if you need further information on how to use them.
This code, will extract the data in all the A tags inside the P tag, but there is a small setup you need to do, I use XPATH to get the path of the A tags.
Please install:
XPath Checker By Brian Slesinsky
or
how to find the xpath of an element (I would recommend the chrome console method)
with this you need to right click on the a tag and give View XPATH, this will give you an XPATH like
/x:html/x:body/x:p/x:a[2]
Then, after you get this X path you need to paste it in the Xpath value (Note you need to remove the x: from the above XPATH before pasting. Also note the number in the [] of the Xpath indicates the child number, since we use !LOOP to set the line number we ignore [2]) of the tag, refer the below code where I have done the same with the above Xpath
Note:
1. Please loop the imacros code according to the number of A tags you want to extract.
2. You also need to update the folder attribute of SAVEAS line, to your desktop path.
Code:
SET !LOOP 1
SET !ERRORIGNORE YES
TAG XPATH=(/html/body//p/a)[{{!LOOP}}] EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=C:/Users/Test/Desktop/ FILE=output.csv
The list is in the form of:-
0:
https://url
1:
https://url
..... And so on.
How could I loop on this list. So I could fetch the number first without ":" and type it somewhere then fetch the url that comes after that number and type it elsewhere. Then end repeat if the list is over.
Or should I use records instead?
I am still a beginner using AppleScript. I tried many commands I mixed up but the computer keeps running the script nonestop and the activity monitor shows the applescript using 100% of the processor and huge amount of ram.
Appreciate any help.
Thank you
You didn't define what your list really looks like very well so I made an assumption on my answer below. If I was wrong, hopefully my answer will at least point you in the right direction. (or if I've gotten it wrong, but you can choose to reformat it to the way I suggested, that could still help)
on run
set theList to {"0:http://apple.com", "1:http://google.com"} -- my guess at what your list looks like.
repeat with anItem in theList
set anItem to anItem as string
set itemParts to myParseItem(anItem)
set tID to the_integer of itemParts as integer
set tURL to the_url of itemParts as string
end repeat
end run
on myParseItem(theItem)
set AppleScript's text item delimiters to ":"
set delimitedList to every text item of theItem
set newString to (items 2 thru -1 of delimitedList as string)
set AppleScript's text item delimiters to {""}
set theInt to item 1 of delimitedList
set theURL to newString as string
return {the_integer:theInt, the_url:theURL}
end myParseItem
I'm currently trying to make an if/else statement, however i wont manage to get it working...
This is my code:
SET !ERRORIGNORE YES
URL GOTO=https://en.wikipedia.org/wiki/Main_Page
WAIT SECONDS=2
SET !VAR1 {{!URLCURRENT}}
PROMPT {{!VAR1}}
WAIT SECONDS=2
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(4)>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>UL>LI:nth-of-type(3)>A" BUTTON=0
WAIT SECONDS=2
SET !VAR2 {{!URLCURRENT}}
PROMPT {{!VAR2}}
SET !VAR3 EVAL("var d=\"{{!VAR1}}\"; var s=\"{{!VAR2}}\" ; if (d==s) {var x=https://www.google.de/;}x; else {var y=https://www.youtube.com;} y;")
URL GOTO={{!VAR3}}
(the prompt is to see that the !VAR's are set correctly)
I'm trying to go to wikipedia as example, save the weblink as a VAR1, and go to another page, which i set to VAR2.
After that i want to compare them, and check them and choose if ,like in this case, they are different (which they obviously are) iMacros should go to youtube.
Somebody might help? I don't want to use .js with my iMacros, and i know it is possible, but i dont know how....
I used this code as reference:
REFERENCE LINK FOR THE FOLLOWING QUOTE AND CODE
One Example I quite like is the following: (I need to switch on the
Light in some Game between 20h-08h by pressing a Switch On/Off Button
on the Page. Then I use:)
SET Light EVAL("var d=\"{{!NOW:hh}}\"; if ((d>7)&&(d<20)) {var x=0;} else {var x=1;} x;")
TAG POS={{Light}} TYPE=IMG ATTR=SRC:http://website.com/images/b_light_on_off.gif
Okay, i got it working for me, added some comments on it
URL GOTO=https://en.wikipedia.org/wiki/Main_Page
WAIT SECONDS=1
'Set the VAR1 to the current url= https://en.wikipedia.org/wiki/Main_Page
SET !VAR1 {{!URLCURRENT}}
WAIT SECONDS=1
URL GOTO=https://en.wikipedia.org/wiki/Portal:Featured_content
WAIT SECONDS=1
'Set the VAR2 to the current url= https://en.wikipedia.org/wiki/Portal:Featured_content
SET !VAR2 {{!URLCURRENT}}
' 1.Now !VAR3 is our answer from the if statement
' 2.We need to assign the text from {{!VAR1}} to a var x,y,z,...
' In this case, we use the letter d and s, and assign text with \"....\" to the var
' 3.We check if d and s are equal by if (d==s), there is also not equal (d!=s)
' Or bigger(but only for numbers) (d>s) or smaller (d<s)
' 4.After the if we say what !VAR3 should become if the if statement is right
' This is done by creating a new var (in this case the x)
' However the output shall be again a text, so we assign x to https://www.google.de
' And do this by assigning text to a var with \"....\" so in this case {var x = \"https://www.google.de\";}
' 5.After that we add the else, if the statement was false, and assign x to the text, which should
' !Be VAR3 when the statement was wrong, and we do this again the same way so in this case {var x=\"https://www.youtube.com\";}
' 6. At the end we "call" x and tell that whatever x has become, it is now !VAR3
SET !VAR3 EVAL("var d=\"{{!VAR1}}\"; var s=\"{{!VAR2}}\" ; if (d==s){var x = \"https://www.google.de\";} else {var x=\"https://www.youtube.com\";} x;")
'checking if code worked (and it did)
URL GOTO={{!VAR3}}
'you can of course change the SET !VAR1 or !VAR2 to some text inside a page, or whatever you like
So, I have this RegEx that captures a specific string I need (thanks to Shawn Mehan):
>?url:\'\/watch\/(video[\w-\/]*)
It works great, but now I need to mod my criteria. I need to capture ONLY the first URL after EACH instance of: videos:[{title:. Bolded all instances below and also bolded the first URL I'd want captured as an example.
How might I approach this? I have a VBScript that will dump each URL to a text file, so I just need help selecting the correct URLs from the blob below. Thinking something like, "if this string is found, do this, loop". Setting the regex global to false should only grab the first instance each round, right? A basic example would help.
I believe I have all of the pieces I need, but I'm not quite sure how to put them together. I'm expecting the code below to loop through and find the index of each instance of "videos:[{title:", then the regex to grab the first URL after (regexp global set to false) based on the pattern, then write the found URL to my text file, loop until all are found. Not working...
(larger portion of html_dump: http://pastebin.com/6i5gmeTB)
Set objWshShell = Wscript.CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objRegExp = new RegExp
objRegExp.Global = False
objRegExp.Pattern = ">?url:\'\/watch\/(video[\w-\/]*)"
filename = fso.GetParentFolderName(WScript.ScriptFullName) & "\html_dump.txt" 'Text file contains html
set urldump = fso.opentextfile(filename,1,true)
do until urldump.AtEndOfStream
strLine = urldump.ReadLine()
strSearch = InStrRev(strLine, "videos:[{title:") 'Attempting to find the position of "videos:[{title:" to grab the first URL after.
If strSearch >0 then
Set myMatches = objRegExp.Execute(strLine) 'This matches the URL pattern.
For Each myMatch in myMatches
strCleanURL = myMatch.value
next
'===Writes clean urls to txt file...or, it would it if worked===
filename1 = fso.GetParentFolderName(WScript.ScriptFullName) & "\URLsClean.txt" 'Creates and writes to this file
set WriteURL = fso.opentextfile(filename1,2,true)
WriteURL.WriteLine strCleanURL
WriteURL.Close
else
End if
loop
urldump.close
var streams = [ {streamID:138, cards:[{cardId: 59643,cardTypeId: 48,clickCount: 84221,occurredOn: '2015-08-17T15:30:17.000-07:00',expiredOn: '',header: 'Latest News Headlines', subHeader: 'Here are some of the latest headlines from around the world.', link: '/watch/playlist/544/Latest-News-Headlines', earn: 3, playlistRevisionID: 3427, image: 'http%3A%2F%2Fpthumbnails.5min.com%2F10380591%2F519029502_3_o.jpg', imageParamPrefix: '?', size: 13, durationMin: 15, durationTime: '14:34',pos:0,trkId:'2gs55j6u0nz8', true,videos:[{title:'World\'s First Sky Pool Soon To Appear In South London',thumbnail:'http%3A%2F%2Fpthumbnails.5min.com%2F10380509%2F519025436_c_140_105.jpg',durationTime:'0:39',url:'/watch/video/716424/worlds-first-sky-pool-soon-to-appear-in-south-london',rating:'4.2857'},{title:'Treasure Hunters Find $4.5 Million in Spanish Coins',thumbnail:'http%3A%2F%2Fpthumbnails.5min.com%2F10380462%2F519023092_3.jpg',durationTime:'0:54',url:'/watch/video/715927/treasure-hunters-find-4-5-million-in-spanish-coins',rating:'4.25'},{title:'Former President Jimmy Carter Says Cancer Has Spread to Brain',thumbnail:'http%3A%2F%2Fpthumbnails.5min.com%2F10380499%2F519024920_c_140_105.jpg',durationTime:'1:59',url:'/watch/video/716363/former-president-jimmy-carter-says-cancer-has-spread-to-brain',rating:'2.8889'},{title:'Josh Duggar Had Multiple Accounts on AshleyMadison.Com',thumbnail:'http%3A%2F%2Fpthumbnails.5min.com%2F10380505%2F519025222_c_140_105.jpg',durationTime:'1:30',
Assuming that your input comes from a file and is in correct JSON format you could do something like this in PowerShell:
$jsonfile = 'C:\path\to\input.txt'
$json = Get-Content $jsonfile -Raw | ConvertFrom-Json
$json.streams.cards | ForEach-Object { $_.videos[0].url }
The above is assuming that streams is the topmost key in your JSON data.
Note that the code requires at least PowerShell v3.
I am new to Imacros and simply trying to extract order information from a page and sometimes the order information contains a telephone number sometimes not.
I want to have a simple if else statement in imacros script to check if the phone number is null/ empty, if it is use my default phone number in its place, any help with this would be useful, thanks in advance
VERSION BUILD=8070701 RECORDER=CR
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 10
SET !TIMEOUT_TAG 0
TAB T=1
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:frmSubmit ATTR=ID:dayphone2 EXTRACT=TXT
SET !VAR7 {{!EXTRACT}}
SET !EXTRACT NULL
'THIS IS THE ACTION I NEED - NOT IN THE CORRECT IMACROS FORMAT
if (VAR7 == NULL) { SET !VAR7 = '0800 00097777}
I need VAR7 set to my default phone number if the value is empty from the extraction
thank for looking
With command "EVAL" it's a simple thing:
SET !VAR7 EVAL("if (\"{{!VAR7}}\" == 'NULL') '0800 00097777'; else \"{{!VAR7}}\";")
Check only that !VAR7 is really NULL, but not "" (for example).