Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 37

Thread: copy a table

  1. #11
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You have another idea which will make it possible to take only one table of the page without forgetting that table source will make it possible my table to remain up to date

    but I does not include/understand why the preceding idea is bad but good I do not know anything large thing in php

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    djr33's other idea using file_get_contents() is sound.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    do you have another idea?
    I will test all the ideas suggested

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That's how I'd do it. I don't see a reason to use anything else.

    Now this is a very bad idea. That HTML page will be included -- and executed as PHP code. It effectively gives the owner of the remote server access to your server with the access rights of the server process -- which is enough to much up your files and probably steal a database password or two, at least.
    No... for security, pages on other servers are executed as plain text, passed directly to the output buffer. No?
    It certainly can't grab PHP files off the server. I suppose they could embed plain text php code in the page, but I don't think that would be executed.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #15
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    with what had begun you to explain to me Ca will be possible?

    if I says that it must take the beacon <td> which is right after the title of the table and post it until the end of the </td>

    it is possible that?

  6. #16
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You could post a link, as I said before, and we could give you an example.


    Look at this:

    212141423232141422

    Let's say you wanted to find the bold "1".

    Well, just finding one would return the second character.

    It's between two "4"s. That's helpful.

    substr($string,strpos($string,'4'),strpos($string,'4',strpos($string,'4'))-strpos($string,'4'));
    That would find the string between the first four, and the next four after it.

    But... there's another 4, earlier in the page. What now?

    Well, let's make the whole thing be AFTER the pattern "321":
    $string = substr($string,strpos($string,'321');
    //then use the line above


    So, basically, the point is that you would need to narrow it down, and be sure that what you search for won't change.

    If you were to grab an email from a page in this format:
    <b>Name</b>: Some One
    <b>Email</b>: some@one.com
    <b>Site</b>: some.com

    You would know to look for the word "Email" in the text. But even better, the string "<b>Email</b>:", because that won't be repeated anywhere else in the text (at least the odds are for it).

    Then get the text after it, but only up to the next line break.

    That's the basic idea, and we can't answer any more questions without knowing the exact pattern being searched.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #17
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I sent a bond by private message to you

  8. #18
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ok, I got the message, and replied with the code there.

    For anyone else to reference, here's some code that should work, though it is specific to the page in question:

    PHP Code:
    <?php

    function get_table($page,$b) {
    $f file_get_contents($page);
    $st strpos($f,'<table',strpos($f,'<b>'.$b.'</b>'));
    $fn strpos($f,'</table>',strpos($f,'<table',strpos($f,'<b>'.$b.'</b>')))-strpos($f,'<table',strpos($f,'<b>'.$b.'</b>'));
    return 
    substr($f,strpos($f,'<table',$st,$fn);
    }

    echo 
    get_table('http://the.com/page.htm','D+');

    ?>

    This solution will work for most cases, but sometimes there might be something weird that happens, like a table in the middle of the table, and it gets confusing.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #19
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    An enormous mercy,

    I test that and I keeps you informed

    thank you thank you

  10. #20
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    And the link which is in echo, it is my URL of my site which I must put with the bond of the page or the new table or the page of the old table will be?

Bookmarks

Posting Permissions

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