Extracting text & reusing it?

Discussion in 'PHP' started by Raizan, May 1, 2010.

  1. #1
    So what i'm requesting would probably work best if there was a rss feed for the source that i'm taking information from ... but that source doesn't have rss. So I'll have to do things manually :/

    This is just a small project i'm doing for class, for a website like:
    http://osoc.berkeley.edu/OSOC/osoc?...nits=&p_restr=&p_info=&p_updt=&p_print_flag=Y

    or

    http://osoc.berkeley.edu/OSOC/osoc?...g=&p_units=&p_restr=&p_info=&p_updt=&x=36&y=9

    I want to be able to extract all the info on that page & re-display them (ie reformat how the information is displayed i guess).

    I can format the data once i've gotten it...my only dilemma right now is how to extract the information in such a way that it'll be reusable?
     
    Raizan, May 1, 2010 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use file_get_contents to retrieve the content, and you can then use a regular expression to parse out all of the data
     
    JAY6390, May 2, 2010 IP
  3. Raizan

    Raizan Peon

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks! but now another problem, how do I extract the html contents from and to only a certain section?
    so say for something like:

    http://osoc.berkeley.edu/OSOC/osoc?...=&p_units=&p_restr=&p_info=&p_updt=&x=34&y=14

    i don't want all the html/contents, i just want the part that actually lists the schedules. Is that possible?

    Also, i'm guessing I would use the strip_tags to strip the html codes I don't want from the extracted result?

    My little program does only the following: allow user to make a schedule search, fetch the actual result from the berkeley schedule site, then strips html tags unneeded and then display everything else on a new page - that's all possible within the realm of PHP right?
     
    Raizan, May 2, 2010 IP
  4. ched

    ched Active Member

    Messages:
    185
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #4
    Depending on the structure of the page you can use the php function 'explode' It will enable you to break the page up into sections and put them in an array.
    Hopefully that gives you an idea?
     
    ched, May 2, 2010 IP