Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Check for popups in webpage
by teabag (Pilgrim) on Jul 19, 2003 at 21:55 UTC
    Young Anonymous,

    It's not about wanting and needing, but about sharing and contributing. So I'll help you out a little with this "working" script.
    You'll have to change some things to get it working entirely with just perl instead of using system calls ;).

    So it's up to you to:


    • look up what strict does and to implement it.
    • Look for what other javacode makes popups appear and implement the matching of it.
    • See why the LWP-module is so very nifty, and usefull if you don't have lynx ;).
    And thus completely rewrite this quick and dirty example.

    To speak with the unforgettable words of Janice Joplin, "Try-ha-ha-ha-ha, just a little bit harder".

    #!/usr/bin/perl -w #popuppagechecker.pl $url = "empty";#;) if ($ARGV[0]) { $url = $ARGV[0]; } if ($url eq "empty"){ print "Specify url like popuppagechecker.pl http:\/\/www.makemyhomewor +k.com\n"; exit; } open TEL, "lynx -source $url|"; @text = <TEL>; $darnpopup = "false"; # teabags full report ;) print "@text\n$url"; foreach $line(@text){ if ($line =~ m/window.open/g){ print " probably has popups, (or some other lame javascript....)\n"; $darnpopup = "true"; } } if ($darnpopup ne "true"){ print " probably has no popups\n"; }

    Hmm, I just realised fixing the above code sounds even like more homework then you're in for! hehe...

    Teabag
    Sure there's more than one way, but one just needs one anyway - Teabag

      Hmmm... I checked out the LWP Module and I was wondering how you intend to use this as a pop-up killer. Were you intending to use it to create a web browser? Maybe I'm missing something here, but this is very interested for me, and thanks for the note for LWP anyways since it looks like a really cool module.

        Whereas the title does did say 'popup killer', the actual requirement is "can check for popups in any other web page and report it". The script teabag provided simply grabs a web page and checks to see if the string window.open is present and does something if it is. This definitely fills the requirement. The title, while eye catching, doesn't exactly describe the content very well, IMHO (i am fixing to consider it for retitling).

        Also, if you think LWP is cool, check out LWP::Simple and WWW::Mechanize.

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
      Hi , Thanks for ur help but let me specify u where I am stuck . I open a web page in netscape like yahoo.com or rediff.com or any web page in the world. I then start my perl popup killer script . Now my problem lies in getting the text contents of the web page .How can I get the web page contents of yahoo.com or rediff.com or any web page from the browser window .Mostly i can hard code the url which i don't want since I can open any web page in the browser and I want to retrieve the text contents of the opened web page in browser . Eg : If i open yahoo.com then i should be able to retrive the yahoo.com web contents i.e text and check for popup. If i open rediff.com then i should be able to retrive the rediff.com web contents i.e text and check for popup. Can u suggest me on how I can do it . Please let me know on the above problem . Bye

        Since, as was pointed out to you ( or someone like you) in another node, you'd need to have your script interact with the Netscape application, this is hard to make work on Unix.

        Therefore, your script would have to be a proxy, sitting between your Netscape and the Web, so it could see all the pages you retrieve and check them. Of course, if you judt want to kill the popups (and don't want to use Mozilla for some reason), you could use junkbuster - as this is a proxy that sits between your browser and the web watching what goes by and acting on it.

        Otherwise, tell your professor he's asking for the impossible (or near impossible).

        Update: You could run the code previously suggested in a loop that waited for a URL to be given on STDIN, then checked the page and repeated. Then you could copy and paste the URLs from the Location field in Netscape to the treminal where your script is running. Other than that, good luck.

        --Bob Niederman, http://bob-n.com
Re: Check for popups in webpage
by bobn (Chaplain) on Jul 19, 2003 at 20:28 UTC

    We all have our wants.

    --Bob Niederman, http://bob-n.com
      Hi , I am sorry to demand . I just need the logic on how I should go abt it . I just don't know that how can i make this application in perl . Thankyou !
A reply falls below the community's threshold of quality. You may see it by logging in.