Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Howto extract a webpage data using php and show on html ?

    Can anyone show me an example, that
    using a php (not vbs, hope to run on linux) to extract certain predefined
    lines (actually news) on another internet site page and then show on my
    own web page in html table ??



    news site: http://www.rthk.org.hk/rthk/news/expressnews/ (sorry big5)

    I want to show dynamic news info like the util http://www.samurize.com

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    This is Javascript forum and not PHP forum. Wait for the mod to move it there.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [reply] sorry

    Sorry,

    Wrongly posted.....


  • #4
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would use something like cURL or Snoopy. This will get you the html source. Then I think you can use your own methods to grab the data you want, perhaps regular expressions or something.

    I was going to do something like this at one time, but then I realized that my solution was highly dependent on their web layout. If they changed ONE little thing, it could very possibly break my code.

    But yea, do some research on cURL and Snoopy and I'm sure you'll be on the track you want to be on. Then if you have any specific questions/problems, post them in the PHP forum.

    Good luck,
    Sadiq.

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [repl] thanks

    Thanks.

    Both cURL and Snoopy need install to Linux, windows cannot ?

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've installed cURL on Windows... I don't know about Snoopy, but you should be able to..

    http://www.tonyspencer.com/journal/00000037.htm

    Let me know if you can't figure it out.

    Sadiq.

  • #7
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,

    But just wonder if a php script cannot do the extraction itself without installing any software ??

    Sorry I am newbie to php.

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It can, but it's not easy and that's the reason cURL and Snoopy were written (libraries to encapsulate this).

    I remember coming across links on how to do it, but it's not the easiest thing to do. Perhaps someone else can suggest how to do it without cURL or Snoopy. My suggestion would be to look at cURL or Snoopy's source code, but that might not be the easiest thing for you either!

    I would say to get one of them and look at some online tutorials and you should be on your way.

    Sadiq.

  • #9
    New Coder
    Join Date
    May 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up [query]

    I have try with a single new.php to read all the html source code (text) from a web. (without using cURL and Snoopy - that I don't want to use - I only use fopen and fget).

    I still have some query:

    1) my web first page in a index.html and contain javascripts and java applets.
    how to call the new.php and get the data return into my index.html ?
    2) if I change the first page to index.php (and get the data from the site
    required, extract data in a array etc) ; how php can handle my original
    javascripts and java applets ?

    Hope any one advise a little bit detail of sample script.

    Thanks very much.
    Matthew

  • #10
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,071
    Thanks
    11
    Thanked 96 Times in 94 Posts
    Snoopy is not a server library/dll but simply a script using raw PHP functions todo the fetching , its a helper class for exactly what you want to do.

    if you want to fetch HTTPS then snoopy requires cURL else should work as is (on any platform) , check out the sample in the download.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •