Noodle105 wrote: ↑Sat May 02, 2020 2:54 pm
Code: Select all
VERSION BUILD=10022823
iMacros 10 Browser
Windows 10
First of all, apologies for my naivety in this subject. I'm still pretty new to all this.
Basically I'm looking to write a code that goes to a user on a website, and if it finds the words 'Status: Online' it saves the username to an online.txt file, and if the username is offline it saves it to a offline.txt file, and then moves on to the next username, which would be given by {{!COL2}}.
Now I understand that the macro is searching for Status: Online or Status: Offline, but then the extract command is mutually exclusive regardless of whether or not it finds the text on the page anyway.
Thus when I run the script, it saves the username to both the Online file, and the Offline file.
Here's what I have so far:
Code: Select all
SET !DATASOURCE filter.csv
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
FILTER TYPE=IMAGES STATUS=ON
URL GOTO=www.test.com/user={{!COL1}}
SEARCH SOURCE=TXT:"Status: Online"
'TAG POS=9 is the location of the username
TAG POS=9 TYPE=FONT ATTR=* EXTRACT=TXT
SET !CLIPBOARD {{!EXTRACT}}
SAVEAS TYPE=EXTRACT FOLDER="my filepath" FILE=Online.txt
SET !EXTRACT NULL
SEARCH SOURCE=TXT:"Status: Offline"
'TAG POS=9 is the location of the username
TAG POS=9 TYPE=FONT ATTR=* EXTRACT=TXT
SET !CLIPBOARD {{!EXTRACT}}
SAVEAS TYPE=EXTRACT FOLDER="C:\\Users\\cooki\\Desktop\\Users Online" FILE=Offline.txt
SET !EXTRACT NULL
Any help to get me on the right path would be greatly appreciated. Thank you!
"Hep needed with" has no "real" Use in a Thread Title on a Tech Forum...
Your Thread will probably get moved to the 'Data Extraction' Sub-Forum... I still approved it because the overall Quality is OK, and the 'General' Sub-Forum is always "OK" if you are "unsure" about which Sub-Forum to choose to open your Thread, but mention in that case that you "hesitated" about which Sub-Forum to select, or I usually don't answer when Threads are open in a "wrong" Sub-Forum...
Hum, iMB v10.0.2 is a bit of a "strange" Version to use for sbd who's "still pretty new to all this", as it is already 5 or 6 years old, and I guess you've probably downloaded some Pirated Version from some "obscure" Website, ah-ah...!
(But don't "worry", the Forum is about (Advanced) Users helping Users, we don't "care" about Licensing and "pirated Versions", oops...!
)
But hum, there are maybe some "better" or at least more recent Versions you could use..., and all legal/legit, without needing to use some 'Pirated" Version, ah-ah...!:
- Current Versions for FF and CR are respectively v10.0.2 for FF (+ FF[56-76+]) and v10.0.5 for CR (+ CR[60-81+]), which both come in a 'Free' + 'PE' (= "Personal Edition") Versions, but you would need the 'PE' Version in your Case (which is not Free), because of the 'SAVEAS' Functionality.
- Current Version for IE is v12.6, also with 'Free' + 'PE' Versions, but the 'SAVEAS' Command is supported in the 'Free' Version.
- Current Version for iMB is v12.6 also, but there is only a 'Trial' Version, it's not "Free"...
- Another 'Free' Version that supports 'SAVEAS' (and much more...!) is v8.9.7 for FF, that works until FF56 (recommended = FF v55.0.3) or in Browsers forked on FF that didn't adopt the 'WebExtensions' Architecture, like 'Pale Moon' (=> PM28) or 'Basilisk' (=> v2019/2020) for example...
>>>
Alright..., hum, interesting Term, this "Assertion", it surprisingly doesn't get used much on the Forum, 1st time I use it myself, I think...
For the Functionality that you want in your Script, you want only 1 'SAVEAS' Command indeed, or your Script will save twice some Data to both Files like you describe..., and you need to "compute" dynamically the Filename to which File you want to save, depending on if 'Status' = "Online" or "Offline" gets found.
For this you'll need the 'EVAL()' Command, to "analyze" the Result of both 'SEARCH' Commands, and to spit out "Online.txt" or "Offline.txt" to reuse for the 'SAVEAS'.
>>>
And hum..., I never use the 'SEARCH' Command myself..., as I don't "like it", and there are easier and more "powerful" Techniques to get the same "Result" and much more "Applied Functionality"...: It might be easier to "directly" try to tag both "Status: On/Offline" Elements (+ 'EXTRACT=TXT' maybe), + extracting your 'Username' using 'Relative Positioning'...
It can probably also be done with just 1 'TAG'/'EXTRACT' Statement on "Status:<SP>O*line" + extracting the 'Username', with or without 'Relative Positioning', the "O*line" will already return "Online" or "Offline" that you can directly reuse for the Filename, you don't even need any 'if'/'else' Condition(s)... That would be the most straightforward Implementation, I would think...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...