Retreive information from another site

Discussion in 'PHP' started by GLD, Jul 15, 2007.

  1. #1
    Hi there,

    I'd like to retreive 3 pieces of information about TV episodes from TV.com: the airdate, the writer and the director of the episode, e.g. from here.

    Does anyone know how I can do this?

    Could I do this for example by retreiving the source code of the page, and then using strpos()?
     
    GLD, Jul 15, 2007 IP
  2. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yep, essentially you want to grab the page source code using sockets, file_get_contents (probably the simplest) or curl and then extract the data generally using regular expressions. strpos and similar functions could probably be used but regular expressions give you more flexibility and will be easier in the long run (although the learning curve is admittedly steeper).
     
    streety, Jul 15, 2007 IP
  3. GLD

    GLD Well-Known Member

    Messages:
    307
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #3
    I'm having trouble outputting the source code of the page using PHP - when I use file_get_contents I get the following error:

    Could someone please explain how I can output the source code?
     
    GLD, Jul 16, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    That means allow_url_fopen has been disabled in php.ini.

    Either try to talk to the guys from your hosting and ask if they can enable it, or see if cURL is installed.
     
    nico_swd, Jul 16, 2007 IP
  5. GLD

    GLD Well-Known Member

    Messages:
    307
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Thanks. :)

    I have found a cURL solution.
     
    GLD, Jul 16, 2007 IP
  6. glowdot

    glowdot Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You might want to see if you can pull that information from one of their feeds:

    http://www.tv.com/feature/rss/

    That way, if they decide to change something ever so slightly, you won't need to completely rewrite your code.
     
    glowdot, Jul 16, 2007 IP