it looks like it is something with the URL but i'm not sure on the best fix for it. I rewrote my code for testing which is below
Code:
<?php
// main page to get link from
$data = file_get_contents('http://www.reed.co.uk/job/searchresults.aspx?s=174&sr=1&FromSector=1&pg=3');
// Get first
$location1 = strpos($data,"<h4><a href=\"");
$location1 = ($location1 + 13);
$location2 = strpos($data,"\">", $location1);
$next = $location2;
$location2 = ($location2 - $location1);
$urlsite = substr($data,$location1,$location2);
echo "<b>Extracted Link :</b>".$urlsite."<br /><br />";
$url = "http://www.reed.co.uk";
//$url .= urlencode($urlsite);
$url .= $urlsite;
echo "<b>Combined Link :</b>".$url."";
echo "<br /><br />";
echo "Test 1:";
$data = file_get_contents('http://www.reed.co.uk/job-details/Spalding/Accounts-Admin/ledger-clerk/?JobID=17817202&&pg=3&s=174&sr=1&FromSector=1&lit=2"%20id="ctl00_Main_rptJobSearchResults_ctl00_lnkJobtitle');
if(!$data){
//die("File get contents is broke");
}else{
Echo "data get success<br /><br />";
}
echo "Test 2:";
$data1 = file_get_contents($url);
if(!$data1){
//die("File get contents is broke");
}else{
Echo "data1 get success";
}
?>
Here is the oputput
Code:
Extracted Link :/job-details/Spalding/Accounts-Admin/ledger-clerk/?JobID=17817202&&pg=3&s=174&sr=1&FromSector=1&lit=2" id="ctl00_Main_rptJobSearchResults_ctl00_lnkJobtitle
Combined Link :http://www.reed.co.uk/job-details/Spalding/Accounts-Admin/ledger-clerk/?JobID=17817202&&pg=3&s=174&sr=1&FromSector=1&lit=2" id="ctl00_Main_rptJobSearchResults_ctl00_lnkJobtitle
Test 1:data get success
Test 2:
Warning: file_get_contents(http://www.reed.co.uk/job-details/Spalding/Accounts-Admin/ledger-clerk/?JobID=17817202&&pg=3&s=174&sr=1&FromSector=1&lit=2" id="ctl00_Main_rptJobSearchResults_ctl00_lnkJobtitle) [function.file-get-contents]: failed to open stream: HTTP request failed! in C:\wamp\www\php_sandbox\rework1.php on line 33
The only differance I can see in the two links is a %20 I tried urlencode but cant seem to make that work. anyway I posted the full code so if anyone is interested they can try it themself.. The only other way I can think of is inserting the %20 into the string myself..
Thanks again for them help
Bookmarks