Here is my code.
I want to modify the $new_ch for $new_ch[]. Is it viable for curl_init() this function? I want an array with an auto increment for each $new_ch so that I am curious about the array with curl_init() this function. Wish you reply. Thanks.
<?php
$count = 0;
$judge = fopen($sourcefile,"r+");
while(!feof($judge))
{
$destination = fgets($judge);
$new_ch = curl_init();
curl_setopt($new_ch, CURLOPT_URL, $destination);
curl_setopt($new_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($new_ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($new_ch, CURLOPT_MAXREDIRS, 4);
curl_setopt($new_ch, CURLOPT_TIMEOUT, 30);
curl_setopt($new_ch, CURLOPT_USERAGENT, $agent_name);
curl_setopt($new_ch, CURLOPT_COOKIEFILE, $cookie_jar);
$getinner = curl_exec($new_ch);
$saveinner = fopen('./'.$datetime.'/'.$datetime.'.txt',"w+");
fwrite($saveinner,$getinner);
fclose($saveinner);
$dom_new = file_get_html('./'.$datetime.'/'.$datetime.'.txt');
foreach($dom_new->find('a') as $dom_new_element)
{
$needle_new = $dom_new_element->href;
$final_target = preg_match("/txt/",$needle_new);
$final_source = $site_rid.$needle_new."
";
$mytrimaddress = parse_url($final_source, PHP_URL_QUERY);
$eachone = explode("&", $mytrimaddress);
$trimthename = trim($eachone[5]);
$lefttrim = ltrim($trimthename, "/");
$remaintrim = substr($lefttrim, 0, strlen($lefttrim)-1);
file_put_contents('./'.$datetime.'/'.$remaintrim, $final_source);
}
curl_close($new_ch);
$count++;
if($count > 5)
{
exit;
} else {
continue;
}
}
?>
Edit:
At the past moment, I am not sure this way to do like this. So, I asked the question. Most of the command cases I searched on internet are assigned to a variable instead of an array.
I wish some added votes for those post. I also like to help others' question. But, the current reputation is quite low and I am not able to reply any question. Hope you understand my confession.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…