How to fetch / extract data using CURL in PHP?

This is an example that fetches / extracts the information that we get while we search in google as define:words.

Open google.com and type define:zany in search box and press enter.

You will get list for definition of word zany.

In this example, using curl i am demonstrating to fetch the data from that page starting with <ul> tag to </ul> tag.

About the Author

has written 32 stories on this site.

16 Comments on “How to fetch / extract data using CURL in PHP?”

  • generic cialis wrote on 26 April, 2011, 21:14

    Many thanks for providing this post. It is really essential for me.

  • Tessa wrote on 29 April, 2011, 14:37

    I’m not easily ipmrsesed. . . but that’s impressing me! 🙂

  • Wedding planner wrote on 23 July, 2011, 23:49

    Great article thanks

  • chand wrote on 19 August, 2011, 10:22

    hi,
    I need some help like i have api of one service provider and some tracking id’s. they are providing data in xml, and when i am passing id’s by using html text tag and posting to curl it is not coming but id is displaying on url. when i pass id directly it is comming. what to do.

  • admin wrote on 22 August, 2011, 7:52

    Hello chand , thanks for your queries. Please recheck your codes or test by making similar example in your local host. Without seeing actual scenario i cannot help…

  • chand wrote on 22 August, 2011, 10:15

    how to current status from this following file

    http://trackntrace.aflwiz.com/aflwizhtmltrack?shpntnum=84252622306407166

  • admin wrote on 26 August, 2011, 12:11

    Hello Chand, the code below will give you value of first Current Status found on page http://trackntrace.aflwiz.com/aflwizhtmltrack?shpntnum=84252622306407166 . Hope this helps.

    < ?php $url = "http://trackntrace.aflwiz.com/aflwizhtmltrack?shpntnum=84252622306407166"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $var= curl_exec($ch); curl_close($ch); $first= stripos($var,'Current Status',0) ; $second= stripos($var,'</b>',$first) ; $start= stripos($var,'<b>',$first) ; echo substr($var,$start,$second-$start); ?>

  • chand wrote on 29 August, 2011, 13:16

    2011-08-24 16:12

    how to take only date from this in php

  • admin wrote on 30 August, 2011, 5:12

    Hello friend chand, Please send your question clearly in my email mast.ratna@gmai.com so that i can find exact solution and help you. Thanks

  • chand wrote on 2 September, 2011, 12:25

    Thanks a lot for your help.

  • Kumar wrote on 26 April, 2012, 17:10

    How to fetch data in php(curl) from this site http://www.metrorailindia.com 1> i want train fare from one station to another 2> timings of train in current station 3> stations comes between one station to another

  • Gomathi wrote on 13 July, 2012, 4:09

    Good article and informative… keep it rock

  • ruchit wrote on 28 October, 2012, 16:05

    i want to extract and display data(textual and binary data) from a website that provides informations about different cars falling under a specified range of price….can you help me?
    i just want to use these urls in my database and search for the required data by crawling through these websites.

  • sujitha wrote on 5 January, 2013, 9:41

    thank u .it helps me alot

  • Sachin wrote on 27 June, 2013, 12:11

    Thanks a lot, much needed info. keep it up.

Trackbacks

  1. Syntax highlighter not working in ie.. | WordPress Stack Exchange Monitor

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

*

Copyright © 2017 Programmer to Programmer- A website for web programming and mobile application programming tutorials.
Wordpress themes