punith_kumar Posted February 20, 2009 Share Posted February 20, 2009 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] Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted February 20, 2009 Share Posted February 20, 2009 Wrong forum... people don't write your code here Quote Link to comment Share on other sites More sharing options...
corbin Posted February 20, 2009 Share Posted February 20, 2009 Uh, instead of bothering parsing it out, why not just convert from centimeters to inches your self? Quote Link to comment Share on other sites More sharing options...
farkewie Posted February 20, 2009 Share Posted February 20, 2009 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. Quote Link to comment Share on other sites More sharing options...
punith_kumar Posted February 20, 2009 Author Share Posted February 20, 2009 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! Quote Link to comment Share on other sites More sharing options...
farkewie Posted February 20, 2009 Share Posted February 20, 2009 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 Quote Link to comment Share on other sites More sharing options...
punith_kumar Posted February 20, 2009 Author Share Posted February 20, 2009 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! Quote Link to comment Share on other sites More sharing options...
farkewie Posted February 20, 2009 Share Posted February 20, 2009 Ok, Can you post the code you have started using? so we can see where you are up to? Quote Link to comment Share on other sites More sharing options...
punith_kumar Posted February 20, 2009 Author Share Posted February 20, 2009 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... Quote Link to comment Share on other sites More sharing options...
corbin Posted February 20, 2009 Share Posted February 20, 2009 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. Quote Link to comment Share on other sites More sharing options...
punith_kumar Posted February 20, 2009 Author Share Posted February 20, 2009 Hi, I'm not in a position to anwers your questions like why JS because simple I dont know. sorry for this. I'm not going to overload google... and i'm not doing spam. Just these kind of small data i want to show in page... Please help me Quote Link to comment Share on other sites More sharing options...
farkewie Posted February 20, 2009 Share Posted February 20, 2009 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/ Quote Link to comment Share on other sites More sharing options...
punith_kumar Posted February 20, 2009 Author Share Posted February 20, 2009 Hi All, I'm not stealing any content. Just need to get some publicly available info. I'm not against putting "Courtesy: Google". Please let me know you incase any is interested to help me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.