coding fun

O

Owning

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?
 
V

Vincent van Beveren

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
 
O

Owning

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

Vincent van Beveren

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top