• 24-09-2012, 09:35:58
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Arkadaşlar merhaba. Sitedeki kullanıcı adları ve id lerini almak için bir bot yaptım(tamamen amatör olarak)

    Bot siteye giriş yapıyor ve istediğim sayfayı listeliyor.Fakat bu listelen verileri db ye kaydetmek istiyorum (isim ve id olarak) bu konuda yardımcı olabilir misiniz ? Kodları aşağı ekledim. Şimdiden herkese teşekkürler

    <?php
    $username="System";
    $password="12344321";
    $url="http://zerox.ogamespeed.net/index.php";
    $url2="http://zerox.ogamespeed.net/game.php?page=statistics&range=1";
    $cookie="cookie.txt";
    
    $postdata = "username=". $username ."&password=". $password ."";
    $ch = curl_init();
    $ch2 = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url );
    curl_setopt ($ch2, CURLOPT_URL, $url2 );
    
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
    //curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt ($ch, CURLOPT_REFERER, $url2 );
    
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt ($ch, CURLOPT_POST, 1);
    
    $result2 = curl_exec ($ch2);
    curl_close($ch);
    ?>
  • 24-09-2012, 10:30:42
    #2
    Hocam botu yaptın ama veritabanına eklemeyi mi yapamadın? Yoksa botuda başka birinin yardımıyla mı yaptın? Bptu yapan adamın onu hayli hayli yapması lazım.

    mysql_query("Insert into db values('','veri1','veri2')");

    tabi önce veritabanını hazırlaman lazım.
  • 24-09-2012, 12:03:31
    #3
    Yok hocam onu yaparım elbette... Fakat orda listelenen verileri almayı başaramadım

    www.kumko.net/cek.php

    yukardaki adrese yükledim botu. istatistikler sayfası geliyor ve bilgiler listeleniyor. Amacım o listelenen verileri almak.. Onları alamıyorum.
  • 24-09-2012, 13:25:28
    #4
    preg_match('#<th align="left">(.+?)</th>#',$result2,$veri);
    echo $veri[1];
    echo $veri[3];
  • 24-09-2012, 13:52:54
    #5
    Belirttiğiniz doğrultuda aşağıdaki gibi düzenledim. Fakat veri hep boş geliyor. Komple kodu ekledim teşekkür ederim yardımınız için

    <?php
    $baglan = mysql_connect("localhost","veriadi","sifre");   
    if(!$baglan){ die('Bağlantı Hatası:' . mysql_error());}
    $db_select = mysql_select_db("veritabani");
    
    $username="System";
    $password="12344321";
    $url="http://zerox.ogamespeed.net/index.php";
    $url2="http://zerox.ogamespeed.net/game.php?page=statistics&range=1";
    $cookie="cookie.txt";
    
    $postdata = "username=". $username ."&password=". $password ."";
    $ch = curl_init();
    $ch2 = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url );
    curl_setopt ($ch2, CURLOPT_URL, $url2 );
    
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
    //curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt ($ch, CURLOPT_REFERER, $url2 );
    
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt ($ch, CURLOPT_POST, 1);
    //$result = curl_exec ($ch);
    $result2 = curl_exec ($ch2);
    preg_match('#<th align="left">(.+?)</th>#',$result2,$veri);
    mysql_query("insert into veri (veri1, veri2) values ('".$veri[1]."', '".$veri[2]."')") ;
    curl_close($ch);
    ?>
  • 25-09-2012, 09:59:03
    #6
    Bu konuda yardımcı olabilecek birisi yokmu
  • 26-09-2012, 15:16:23
    #7
    PM atmışsınız ancak maalesef bot konularına yardımcı olmuyorum.
  • 26-09-2012, 16:58:44
    #8
    Regex ile ihtiyacın olan verileri seçip, kaydetme işlemini yapacaksın hocam. Regex konusunu araştır.
  • 26-09-2012, 17:14:01
    #9
    <?php 
    function __handle($url,$username,$password){
    		$postdata = "username=". $username ."&password=". $password .""; 
    		$cookie="cookie.txt"; 
    		$ch = curl_init();
    		$timeout = 0;
    		curl_setopt ($ch, CURLOPT_URL, $url);
    		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    		curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
    		curl_setopt ($ch, CURLOPT_HEADER, TRUE);
    		curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
    		curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
    		curl_setopt ($ch, CURLOPT_POST, 1); 
    		$data = curl_exec($ch);
    		curl_close($ch);
    		return $data;
    }
    
    
    $username="System"; 
    $password="12344321"; 
    
    $a = __handle("http://zerox.ogamespeed.net/game.php?page=statistics&range=1",$username,$password);
    
    $Pattern 	= '@<th><a href="#" onmouseover=(.*?) onmouseout=(.*?)>(.*?)</a></th>\s*<th align="left">(.*?)</th>@si';
    preg_match_all($Pattern,$a,$data); 
    
    	for($i=0;$i<count($data[3]);$i++) {
    		
    		echo "NO:". $data[3][$i];
    		echo "<p>";
    		echo "Name:". $data[4][$i];
    		echo "</p>";
    		
    	}