user1687804
user1687804

Reputation: 251

php looping from list

I am making a script. And in this script i will supply some keyword list. And then it will go to a targeted site and grabbing data. Please take a look to my code :

//my option start
$toplist=file_get_contents('http://mysite/list.txt');

//list grabbing

$listgrabbing=explode('target="_',$toplist);
$counting=count($listgrabbing);
$l='0';
for ($l=0 ; $l <=$counting ; $l++){
$targetsite='http://targetsite/search?q='.$listgrabbing;
$revip=file_get_contents($targetsite);

//Rest of code

now see, i have some keyword lists, in a txt file. . Such as :

football
cricket
basketball
chase 

and my code will take first keyword and search into target site and grab. And then second,third,forth... But it is not select keyword from list. What is the error here ?

Upvotes: 0

Views: 85

Answers (1)

Jonathan
Jonathan

Reputation: 585

$toplist=file_get_contents('http://mysite/list.txt');
$listgrabbing=explode("\n",$toplist);
foreach($listgrabbing as $item){
     $targetsite='http://targetsite/search?q='.$item;
     $revip=file_get_contents($targetsite);
}

Upvotes: 1

Related Questions