How do i check if text exists on a website

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
direwolf38
Posts: 1
Joined: Tue Mar 14, 2017 3:40 pm

How do i check if text exists on a website

Post by direwolf38 » Tue Mar 14, 2017 3:44 pm

I need to check if some text exists on a website using javascript, how would i do this?

I've seen some posts saying use "document.". That doesn't work.
Some said use "window.document". That throws an error saying it's not supported in multiprocess firefox.

I've also found this:

Code: Select all

var macro;

macro ="CODE:";
macro +="SET !ERRORIGNORE YES"+"\n";
macro +="TAG POS=1 TYPE=HTML ATTR=TXT:* EXTRACT=TXT"+"\n";

iimPlay(macro)

var text=iimGetLastExtract();

if(text.search("Hello World")!=-1)
{
    alert("Found the text");
}
^That just runs the script...and it finishes. It doesn't throw an error, but it also doesn't "alert" that it found the text. It just runs and finishes.

So how could i do this?
MRTgang
Posts: 8
Joined: Sat Jun 20, 2015 1:32 am

Re: How do i check if text exists on a website

Post by MRTgang » Sat Aug 25, 2018 8:05 pm

i am having the same problem here !
did anyone found a solution for this ?
chivracq
Posts: 8201
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How do i check if text exists on a website

Post by chivracq » Sat Aug 25, 2018 10:27 pm

direwolf38 wrote:I need to check if some text exists on a website using javascript, how would i do this?

I've seen some posts saying use "document.". That doesn't work.
Some said use "window.document". That throws an error saying it's not supported in multiprocess firefox.

I've also found this:

Code: Select all

var macro;

macro ="CODE:";
macro +="SET !ERRORIGNORE YES"+"\n";
macro +="TAG POS=1 TYPE=HTML ATTR=TXT:* EXTRACT=TXT"+"\n";

iimPlay(macro)

var text=iimGetLastExtract();

if(text.search("Hello World")!=-1)
{
    alert("Found the text");
}
^That just runs the script...and it finishes. It doesn't throw an error, but it also doesn't "alert" that it found the text. It just runs and finishes.

So how could i do this?
MRTgang wrote:i am having the same problem here !

did anyone found a solution for this ?
@MRT..., 100s similar Threads on the Forum, many with a Script/Solution, ah-ah...! :roll:

[RANT-MODE=ON] :shock: :shock: :shock:
Hum, most probable Reason I never reacted to this Thread (except that their (from @OP) Thread Title sounded like they were sharing a 'How-to', tja-ah-ah...!, so difficult to locate the '?' when asking for Help or a Qt...) was/is probably the same like for your "Back to the bad Habit", ah-ah...!, tja...! :roll:

Sorry, but if you all have such a mini-Shadok-Brain :shock: , then I can't help you..., my Explanations are usually for Users with a "Brain", oops...! 8)

And I don't even understand actually how you all even manage to remember the Name "iMacros" with that tiny-mini-mini Brain, to be honest... :? (I'm open for Explanations, I might go on a mini-little bit "Softer" on Users on the Forum if I could understand, hum..., maaaaaybe...!?!) :wink:

Oh..., and for both, only from the Thread Title, there are already at least more than 100 similar Threads on the Forum, ah-ah..., and very probably a few with a Solution/Script... (Hum, Confirmation I guess that mini-Brains cannot type 2-3 Keywords to search the Forum..., hum, I thought so already, to be honest... :roll: )

Yeah sorry Guys, my Reply is meant a bit as a complete Joke, but hum..., ah-ah...! :wink:
OK @OP is a bit of a Newbie, but never reacted to the Thread (could have bumped it after a while, or shared their Sol) and @MRT, pfff, 3 year User, sorry, not a Newbie anymore, ah-ah...!, you should know a bit how the/a Tech Forum works..., and be able to search it a bit..., if you managed to find this Thread... :? (That means at least that the Thread Title is a bit correct and Descriptive... :D )
[RANT-MODE=OFF] :wink: :D :wink:
Last edited by chivracq on Sun Aug 26, 2018 2:48 pm, edited 5 times in total.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
Posts: 8201
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How do i check if text exists on a website

Post by chivracq » Sat Aug 25, 2018 11:49 pm

Yep, sorry Guys, that Qt has already been asked HUNDREDS of times, and answered a few Dozens of times, with Script and complete Explanation etc.., is it so complicated to search the Forum...?

=> If you can mention what Keywords you used that you couldn't find any "relevant" Thread(s)...? :o , well... except this one where the User didn't share their Sol, which renders it a bit useless for the Forum and other Users then..., I'm willing to review the "Results" and to add some relevant/extra Search/Meta Keywords to the "good" Threads... :idea:
(... As unfortunately, many Users don't give a very Descriptive Title to their Threads...)

Hum..., and one mini-"Tip", if you are trying to search the Forum for Code Examples using the "obvious" Solution with the 'SEARCH' Command for example, would be to run your Search from 'Google' (+ "imacros" as extra-Keyword of course), as the Internal Forum Search Engine does "strangely" not look inside Code Examples formatted with the ]CODE[ Meta-Tags... unless that Post/Script has later been quoted... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
Posts: 8201
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How do i check if text exists on a website

Post by chivracq » Sun Aug 26, 2018 6:08 pm

One more Remark about this Thread and the original Qt, ah-ah...!

I'm actually nearly surprised there is no 'How-to' Thread about this Functionality in the 'How-to' Sub-Forums, as the same Qt comes back very-very regularly, and like I mentioned there are probably already more than Hundred similar Threads on the Forum... :shock:

I guess the "Reason" is probably/possibly that the Answer/Solution is so "obvious" for TechSupp (=> by using the 'SEARCH' Command, then Users can simply check the Wiki Page for that Command or search the Forum for Script Examples, and for Users who didn't even find it or keep opening similar Threads and asking again and again..., that simply means they didn't read any Documentation nor didn't "really" try to search the Forum, I guess...), that they (TechSupport) never bothered to create a 'How-to' for that...
Hum, fair enough then...

But I know for myself, I don't "like" the 'SEARCH' Command (and I never use it, ah-ah...!) as I find it a bit "complicated" to use as it often requires to use 'REGEXP' that I don't like and don't use either, and I prefer to use other Solutions which I find much easier and more flexible and more "powerful" and often even provide a "Shortcut" onto the next "Action" the Script will have to do upon our Search String being found or not...
And those different Solutions are indeed a bit "scattered" in different Threads on the Forum...
:arrow: => I might write such a 'How-to' myself one day, mentioning all those different Solutions in just one single Thread, if "one day" some User manages to ask the Qt "a bit correctly" in some "Quality Thread", ah-ah...! 8)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply