Merhaba, hava durumu ile alakalı siteme bir bot yapıyorum. Ancak ne yapsam döngüde, dosyadaki şehir idlerini tek tek çekip hepsini bir anda ekrana yazdıramadım.
Öncelikle verileri alacağım site örneği şu şekilde; İstanbul hava durumu =
havadurumusite.com/34111 , Ankara hava durumu =
havadurumusite.com/06111
Ben "/" bundan sonraki idleri tek tek, alt alta tüm şehirlerin ID'sini sehirid.txt dosyasına ekledim.
Foreach döngüsü kurarak veriyi çekiyorum ancak her zaman sehirid.txt dosyasının sonunda bulunan şehrin ID çekerek sadece o şehre ait hava durumunu ekrana yazdırıyor.
Benim isteğim ise tek tek, satır satır tüm şehir idlerini çekerek hepsini bir anda tek ekrana yazdırmasını istiyorum.
Örnek; "Ankara 16' 32', Istanbul 17' 32', Izmir 20' 35' bu şekilde tüm hepsini tek ekranda yazdırmak istiyorum.
Bu konuda yardımcı olabilirseniz sevinirim.
require_once 'simple_html_dom.php';
$html = file_get_html('https://havadurumsite.com');
$sonuc = $html->find('<td>');
$dosya = fopen("sehirid.txt","r");
while($satir = fgets($dosya))
$veri[] = $satir;
foreach ($sonuc as $key){
$url = "havadurumsite.com".$key->href;
$html = file_get_html($url);
echo $havadurum = $html->find('<td>',0);
echo "<br>";
echo $havadurum = $html->find('<td>',1)->plaintext;
echo "<br>";
echo $havadurum = $html->find('<td>',2)->plaintext;
echo "<br>";
echo $havadurum = $html->find('<td>',3)->plaintext;
echo "<br>";
echo $havadurum = $html->find('<td>',4)->plaintext;
echo "<br>";
echo $havadurum = $html->find('<td>',5)->plaintext;
echo "<br>";
echo $havadurum = $html->find('<td>',6)->plaintext;
echo "<br>";
}