Jump to content

Google Search 10.5+cm+in+inches output to html or rss using PHP


punith_kumar

Recommended Posts

Hi,

    Please take a look at the output of google search http://www.google.com/search?q=10.5+cm+in+inches&btnG=Search

    You can see that google directly displays output as first result without going to any website. Now my request is which is the best way to convert only this first output to HTML or RSS using PHP. Please guide me with the code.

 

      I'm newbie to PHP so looking for a working code since I cannot troubleshoot incase it is not working. I have PHP 5.2!

 

      Thanks in advance!

 

[attachment deleted by admin]

Link to comment
Share on other sites

If you want something coded for you put your post in the freelancers forum. there are heaps of guys and girls looking for a bit of cash on the side.

 

otherwise get on the GOOGLE train and start searching, when you have some code that isn't working or spitting out errors post it here with the errors then we will help you learn.

Link to comment
Share on other sites

MatthewJ, Sorry I'm not looking for a big project code... Just sample code because I searched a lot in internet and most of the results are linking to this forum only... So thought somebody will help... Please atleast give me a sample or best method to acheive this.

 

Hope you can understand..

 

corbin, this is to convert dynamically...

 

Farkewie:

      I got this one http://jacksleight.com/blog/2008/02/10/js-extractor-and-the-death-of-table-extractor seems to satisfying my requirement but getting error "Catchable fatal error: Object of class JS_Extractor_Element could not be converted to string in /public_html/lab/ex1.php on line 7"

 

Looking forward for a positive response!

Link to comment
Share on other sites

 

corbin, this is to convert dynamically...

 

 

When you say "dynamically".. PHP is dynamic. is it just calculation of different types that you are wanting from google?

Because if it is corbin is 100% correct. To do the math yourself would be a couple of lines of code compared to gettting it from google. it would also be a faster processing time for your page.

 

http://php.net/math

 

if you really want it from google then

http://au2.php.net/file_get_contents

 

 

Link to comment
Share on other sites

Hi Farkiwie,

      Not only Conversion, I want to do dynamic conversion of "1 USD in JPY" or "Bangalore Wather" for which google gives special output. Please dont consider this as Code Request of lazy boy... I'm puzzled since last two days since I'm not able to perform this task. I know ASP, VB e.t.c but doing this is not possible there easily like PHP... Please help!

Link to comment
Share on other sites

Hi Farkiwei,

    Here os the code I'm trying

 

<?
set_include_path(get_include_path() . PATH_SEPARATOR . './library/');
require_once 'JS/Extractor.php';
$extractor = new JS_Extractor(file_get_contents('http://www.google.com/search?q=10.5+cm+in+inches&btnG=Search'));
$body = $extractor->query("body")->item(0);
$table = $body->query("//table")->item(0);
echo $body;
?>

 

and I get above error message...

Link to comment
Share on other sites

Why would you extract the JS?  Seems easier to extract the HTML to me.

 

 

Or does JS_Extractor emulate accessing DOM elements?

 

 

 

 

Just throwing this out there:  I have moral problems with passing stuff through your site to another site backend.  Seems kind of like a screw-over to google.

Link to comment
Share on other sites

Just throwing this out there:  I have moral problems with passing stuff through your site to another site backend.  Seems kind of like a screw-over to google.

 

I have to agree, If you want something on your site you should create it yourself, pay for it or use public accessible API's such as;

 

Yahoo weather - http://developer.yahoo.com/weather/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.