{"id":5,"date":"2011-02-13T02:58:23","date_gmt":"2011-02-13T02:58:23","guid":{"rendered":"http:\/\/rat32.com\/rat32\/?p=5"},"modified":"2015-08-07T07:36:30","modified_gmt":"2015-08-07T07:36:30","slug":"how-to-fetch-data-using-curl-in-php","status":"publish","type":"post","link":"https:\/\/rat32.com\/rat32\/2011\/02\/13\/how-to-fetch-data-using-curl-in-php\/","title":{"rendered":"How to fetch \/ extract data using CURL in PHP?"},"content":{"rendered":"<p>This is an example that fetches \/ extracts  the information that we get while we search in google as define:words.<\/p>\n<p>Open google.com and type define:zany in search box and press enter.<\/p>\n<p>You will get list for definition of word zany.<\/p>\n<p>In this example, using curl i am demonstrating to fetch the data from that page starting with &lt;ul&gt; tag to &lt;\/ul&gt; tag.<\/p>\n<pre class=\"lang:php decode:true \" >&lt;?php\r\n$url = \"http:\/\/www.google.com\/search?q=define:zany\";\r\n$ch = curl_init($url);\r\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\r\n$var= curl_exec($ch);\r\ncurl_close($ch);\r\n$first= stripos($var,'&lt;ul\u2019,0) ;\r\n$second= stripos($var,'&lt;\/ul&gt;\u2019,0) ;\r\necho substr($var,$first,$second-$first);\r\n?&gt;<\/pre>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>This is an example that fetches then information that we get while we search in google as define:words.<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,3],"tags":[],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-how-to","category-php"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/5"}],"collection":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":17,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":148,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/posts\/5\/revisions\/148"}],"wp:attachment":[{"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rat32.com\/rat32\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}