• 26-10-2023, 10:05:08
    #1
    Merhabalar,

    Aşağıda görüldüğü gibi bir sistem yapmaya çalışıyorum ama kodu yazınca iframe ile bağlanmayı reddetti uyarısı alıyorum. Amacım kodu girince

    https://kargotakip.araskargo.com.tr/...=3076596107489

    bu sayfaya bağlanıp iframe ile ekranda göstermek.

    Bunu nasıl yapabilirim yardımcı olabilir misiniz?



  • 26-10-2023, 10:13:24
    #2
    Iframe engellenmiştir, CURL ile gerekli verileri çekerek yeni bir tasarım yapabilirsiniz. Ancak bu tarz kargo şirketleri eğer direkt olarak bir API hizmeti sağlamıyorsa bu yöntem de sonrasında sorun yaratabilir.
  • 26-10-2023, 12:45:44
    #3
    Aşağıdaki cookie.txt' yolu random oluşan ve veriyi aldıktan sonra sileceğiniz bir çerez olsun.


    <?php
    $domain = 'https://kargotakip.araskargo.com.tr/';
    $url = "{$domain}mainpage.aspx?code=3076596107489&token=076edb2e74f1ec510038b2bc74ecea2f";
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
    curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
    curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    $response = curl_exec($ch);
    
    preg_match_all('<A href="(.+?)" >', $response, $matches);
    
    $invoiceUri = $matches[1][0];
    $activityUri = $matches[1][1];
    
    curl_setopt($ch, CURLOPT_URL, $domain . $activityUri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    
    echo $response;
    
    curl_close($ch);
    
    ?>
  • 26-10-2023, 15:29:06
    #4
    Teşekkür ederim, eline sağlık. Ek olarak bir şey daha soracağım. İlk sekmeyi de yazdırmak istesek nasıl yaparız aşağıdaki kısımlarda değişiklik yaparak denedim ancak ya ilk sekme ya da 2. sekmeyi veriyor aynı anda ikisi birden gelmiyor.

    QuarkChain adlı üyeden alıntı: mesajı görüntüle
    Aşağıdaki cookie.txt' yolu random oluşan ve veriyi aldıktan sonra sileceğiniz bir çerez olsun.


    <?php
    $domain = 'https://kargotakip.araskargo.com.tr/';
    $url = "{$domain}mainpage.aspx?code=3076596107489&token=076edb2e74f1ec510038b2bc74ecea2f";
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
    curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
    curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    $response = curl_exec($ch);
    
    preg_match_all('<A href="(.+?)" >', $response, $matches);
    
    $invoiceUri = $matches[1][0];
    $activityUri = $matches[1][1];
    
    curl_setopt($ch, CURLOPT_URL, $domain . $activityUri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    
    echo $response;
    
    curl_close($ch);
    
    ?>
  • 26-10-2023, 15:42:45
    #5
    Kaynaktaki tablo dışındaki gereksiz HTML etiketlerini kaldırmış oldum.

    <?php
    $domain = 'https://kargotakip.araskargo.com.tr/';
    $url = "{$domain}mainpage.aspx?code=3076596107489&token=076edb2e74f1ec510038b2bc74ecea2f";
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3');
    curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
    curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    $response = curl_exec($ch);
    
    preg_match_all('<A href="(.+?)" >', $response, $matches);
    
    $invoiceUri = $matches[1][0];
    $activityUri = $matches[1][1];
    
    
    curl_setopt($ch, CURLOPT_URL, $domain . $invoiceUri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $buffer = curl_exec($ch);
    $buffer = preg_replace('/\s+/', ' ', trim($buffer));
    $buffer = preg_replace('/>\s+</', '><', $buffer);
    $buffer = preg_replace('/\s+>/', '>', $buffer);
    $buffer = explode('</div><div>', $buffer);
    $buffer = explode('<center>', $buffer[1]);
    $invoiceBuffer = $buffer[0];
    
    curl_setopt($ch, CURLOPT_URL, $domain . $activityUri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $buffer = curl_exec($ch);
    $buffer = preg_replace('/\s+/', ' ', trim($buffer));
    $buffer = preg_replace('/>\s+</', '><', $buffer);
    $buffer = preg_replace('/\s+>/', '>', $buffer);
    $buffer = explode('</div><div>', $buffer);
    $buffer = explode('</div></form>', $buffer[1]);
    $activityBuffer = $buffer[0];
    
    curl_close($ch);
    unlink(dirname(__FILE__) . '/cookies.txt'); // Verileri aldıktan sonra çerezi sil
    
    ?>
    İlk sekme:<br>
    <?php echo $invoiceBuffer; ?>
    <hr>
    İkinci sekme:<br>
    <?php echo $activityBuffer; ?>
    erkanpur adlı üyeden alıntı: mesajı görüntüle
    Teşekkür ederim, eline sağlık. Ek olarak bir şey daha soracağım. İlk sekmeyi de yazdırmak istesek nasıl yaparız aşağıdaki kısımlarda değişiklik yaparak denedim ancak ya ilk sekme ya da 2. sekmeyi veriyor aynı anda ikisi birden gelmiyor.