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 6 of 6

Thread: cURL

  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question cURL

    Hi I was advised that cURL would be fine for what I needed it for. I have looked up and seen that it is possible to strip text. I need to strip everything from one static page all the way down to a certain point. The problem is when I reach this point there is a date or status, so I need it to ignore that and continue to where the "details" code it, this "details" text is a dynamic link, which i then want to follow and then customise certain parts of that pages output. The dynamic page always has the same layout in terms of where everything is positioned, so I really need to work out how I can get a script to go down to the "details" link and follow it, then start customising that?

    Sorry this is the best I can explain it because I have only just heard about cURL and the original idea (in Java) was my idea but my mate designed it, and does not know PHP so even though I know more than him (but nothing compared to most) it is complicated because I am not sure how it works entirly, maybe my other post in the Java forum will help people who want to see for themselves?

    Thanks for any help

    Zack.

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    How about posting the source code for the page to be "striped" and describe what needs to be done b/c I'm not 100% I follow you.

    Is the said page valid XHTML? If so, that'll make it that much easier. Also if you only need to read the page source and parse the source, then you can just use something as simple as fopen() or file_get_contents(). If its valid XHTML you can then just run an XHTML parser to get what you want out of the page. If not, you might have to use a mixture of regular expressions and the explode function. (I know, I know don't yell at me to much.)
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It has a link at the bottom saying it is valid XML, and when I click that there are no errors

    Here is the bit of html I want to strip too
    Code:
    ..........
    <p class="text">The following matches have been started</p>
    
    <table cellpadding="0" cellspacing="0">
    <tr><td align="left" class="text" style="padding:2px 4px">4/8/2007</td><td align="right" class="text" style="padding:2px 4px">Bath City</td><td align="center" class="smallText" style="padding:2px 4px">(1)</td><td align="center" class="text" style="padding:2px 4px">1</td><td align="center" class="text" style="padding:2px 4px">1</td><td align="center" class="smallText" style="padding:2px 4px">(1)</td><td align="left" class="text" style="padding:2px 4px">Tiverton Town</td><td align="center" class="text" style="padding:2px 4px"><a href="myTeamLive.jsp?account=9&amp;match=473">details</a></td></tr>
    I need to get the 473 bit, and then load the 473 page and strip that if you know what I mean, the problem is the 473 could be 481 next time and then 488 then 491. The thing I thought it that the code bits I have highlighted with the score in, all the examples I have seen where it strips the code it includes everything it wants taken out whereas I can not do that because the (1) won't be there before half time, and if it is it won't always be (1), the date is the status so normally a minute number during a game etc.

    The page that it follows onto, is the same layout all the time, but different information, team names etc depending on the match. I only want to keep selected bits of that but that should be fine i just need to know how to get to a position to load it first!

    I hope that makes sense now? Sorry if I am confusing I am new to all this stuff I have never came across this before!

    Thanks again,
    Zack
    Last edited by ZackBCFC; 08-05-2007 at 11:21 AM.

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Here is the XML parser that I use:
    http://www.criticaldevelopment.net/xml/

    If you read the documentation for it you'll see how simple it is to access nodes and values.

    I think I am following you 473 could be any number or n as its really a variable. You need to first find out the match in order to go to the details page for that specific match. Then you must follow that link to the detail page and parse out some more information.

    I think this is simple enough with the XML parser.

    Just use file_get_contents to obtain the source code
    Parse the said source code with the parser
    Get the value of match using the parser
    open that page up and get the source code and parse that
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #5
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by StupidRalph View Post
    Here is the XML parser that I use:
    http://www.criticaldevelopment.net/xml/

    If you read the documentation for it you'll see how simple it is to access nodes and values.

    I think I am following you 473 could be any number or n as its really a variable. You need to first find out the match in order to go to the details page for that specific match. Then you must follow that link to the detail page and parse out some more information.

    I think this is simple enough with the XML parser.

    Just use file_get_contents to obtain the source code
    Parse the said source code with the parser
    Get the value of match using the parser
    open that page up and get the source code and parse that
    Thanks very much, I will try that let you know how i get one but yea thats what I need to do. I was looking for a XHTML parser on google but couldn't find anything that seemed advanced enough. Thanks again will check this out in the morning

  • #6
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi I couldn't get that working, so have adapted this for something I worked on with my mates site a while ago.

    it displays like this http://www.live-updates.co.uk/new2.php which is so far what i want. I now need to get the match number in the top listing, below "the following matches have been started" but can't work out how to get it.

    The annoying this is I have the java for it, but no java will work on the server so im stuck with trying to do this

    PHP Code:
    <?php

        $url 
    "http://livescores.co.uk/myTeamLive.jsp?account=9&match=";
        
        
    $fp fopen$url'r' );
        
        
    $content "";
        

        while( !
    feof$fp ) ) {
        
           
    $buffer trimfgets$fp4096 ) );
           
    $content .= $buffer;
           
        }
        
        
    $start '<td align="center" class="page" colspan="2" style="height:445px">';
        
    $end '<td align="left" class="footer" style="border-width:0px 0px 4px 4px">';
        
        
    preg_match"/$start(.*)$end/s"$content$match );
        
    $info $match]; 

        echo 
    "<div>$info</div>\n";

    ?>
    Last edited by ZackBCFC; 08-10-2007 at 12:47 AM.


  •  

    Posting Permissions

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