coding fun

Discussion in 'Javascript' started by Owning, Jul 15, 2006.

  1. Owning

    Owning Guest

    Hi i am new to javascript, done a bit C coding for school assignment.

    I trying to crate a page that search google, then collect all the ads,
    therefore no search results. Last display display the ads in some
    random layout format?

    Anyone have tips how this could be done?
     
    Owning, Jul 15, 2006
    #1
    1. Advertising

  2. > Anyone have tips how this could be done?

    It can't. For security reasons you can't read from a page outside your
    own domain. You'll need to add some server-side scripting to make that
    work. You could for example, execute the search from your own PHP
    script, and output the results in your own domain, but then again, if
    you do that, you can just as well make the whole thing PHP. You can also
    install tools like Grease Monkey (http://greasemonkey.mozdev.org/) with
    firefox to run scripts on a page, and do something with it.

    Vincent
     
    Vincent van Beveren, Jul 15, 2006
    #2
    1. Advertising

  3. Owning

    Owning Guest

    I have my own server set up! So if i have server its possible to write
    in PHP/JS such a thing?


    Vincent van Beveren wrote:
    > > Anyone have tips how this could be done?

    >
    > It can't. For security reasons you can't read from a page outside your
    > own domain. You'll need to add some server-side scripting to make that
    > work. You could for example, execute the search from your own PHP
    > script, and output the results in your own domain, but then again, if
    > you do that, you can just as well make the whole thing PHP. You can also
    > install tools like Grease Monkey (http://greasemonkey.mozdev.org/) with
    > firefox to run scripts on a page, and do something with it.
    >
    > Vincent
     
    Owning, Jul 15, 2006
    #3
  4. Owning schreef:
    > I have my own server set up! So if i have server its possible to write
    > in PHP/JS such a thing?


    Yes. However, it'll take some work. First in PHP you'll have to make the
    call to google, and redirect the output into a string, or into a page in
    your own domain. You'll basically have two options:

    1. Use PHP as no more than a transfer of the webpage.
    2. Let PHP do the processing.

    In the first case you'll execute a HTTP request through PHP and just
    take the output from that and output it on your own page. You could let
    PHP then append a JavaScript to that output, effectivly making a
    combined page of your JavaScript and Googles output.

    In the second case you'll executre a HTTP request throuhg PHP and
    capture the output in a String. You can then process the page in PHP and
    extract the information you want. After that you'll only output the
    results to your browser.

    The second one is more reliable. However, depending on what your goal is
    with this you might just as well do the first.

    Have fun,
    Vincent
     
    Vincent van Beveren, Jul 15, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    65
    Views:
    1,796
    Mabden
    May 18, 2004
  2. Coding fun

    , Jul 14, 2006, in forum: HTML
    Replies:
    5
    Views:
    575
    Owning
    Jul 14, 2006
  3. calmar
    Replies:
    11
    Views:
    916
    calmar
    Feb 21, 2006
  4. dolphin
    Replies:
    4
    Views:
    330
    Jorgen Grahn
    Aug 25, 2007
  5. er
    Replies:
    2
    Views:
    520
Loading...

Share This Page