By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

coding fun

P: n/a
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?

Jul 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Jul 15 '06 #2

P: n/a
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
Jul 15 '06 #3

P: n/a
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

Jul 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.