Hello,
I am having a problem that is starting to drive me up a wall. I want to pull a certain site using file_get_contents. However I cannot get it to work the way I want. Here is the code:
The echo of $BingCacheURL looks fine but the section that sets $BingCachedSite fails. If I copy the URL that is echo'ed from $BingCacheURL and manually set it, it all works fine. For instance if I change the above to:
it works fine. Please note I replaced my domain name with "somedomain" for this example. I got the above URL from copying it from the output of the first example. It is probably something simple but I can't figure it out. I even did this to check to see if I could see the difference:
They look the same to me. Not sure what is going on. I would appreciate any help.
Thanks,
Chris
I am having a problem that is starting to drive me up a wall. I want to pull a certain site using file_get_contents. However I cannot get it to work the way I want. Here is the code:
Code:
$Domain = "somedomain.com";
$BingSearch = file_get_contents('[URL unfurl="true"]http://www.bing.com/search?q='.$Domain);[/URL]
preg_match('~<a href="[URL unfurl="true"]http://cc.(.*?)>Cached[/URL] page</a>~i', $BingSearch, $BingCache);
if (preg_match('~bing(.*?)" onmousedown~i', $BingCache[1], $BingArray))
{$BingCacheURL = "[URL unfurl="true"]http://cc.bing".$BingArray[/URL][1];} else { $BingCacheURL = "Not Available";}
echo "The Bing Cached URL is: $BingCacheURL<br>";
$BingCachedSite = file_get_contents($BingCacheURL);
echo $BingCachedSite;
The echo of $BingCacheURL looks fine but the section that sets $BingCachedSite fails. If I copy the URL that is echo'ed from $BingCacheURL and manually set it, it all works fine. For instance if I change the above to:
Code:
$BingCacheURL = "[URL unfurl="true"]http://cc.bingj.com/cache.aspx?q=%22somedomain+com%22&d=4649864789426651&mkt=en-US&setlang=en-US&w=d7e1d8f4,cedfa1f9";[/URL]
echo "The Bing Cached URL is: $BingCacheURL<br>";
$BingCachedSite = file_get_contents($BingCacheURL);
echo $BingCachedSite;
it works fine. Please note I replaced my domain name with "somedomain" for this example. I got the above URL from copying it from the output of the first example. It is probably something simple but I can't figure it out. I even did this to check to see if I could see the difference:
Code:
$Domain = "somedomain.com";
$BingSearch = file_get_contents('[URL unfurl="true"]http://www.bing.com/search?q='.$Domain);[/URL]
preg_match('~<a href="[URL unfurl="true"]http://cc.(.*?)>Cached[/URL] page</a>~i', $BingSearch, $BingCache);
if (preg_match('~bing(.*?)" onmousedown~i', $BingCache[1], $BingArray))
{$BingCacheURL = "[URL unfurl="true"]http://cc.bing".$BingArray[/URL][1];} else { $BingCacheURL = "Not Available";}
$BingCacheURL2 = "[URL unfurl="true"]http://cc.bingj.com/cache.aspx?q=%22somedomain+com%22&d=4649864789426651&mkt=en-US&setlang=en-US&w=d7e1d8f4,cedfa1f9";[/URL]
echo "The Bing Cached 1 URL is: $BingCacheURL<br>";
echo "The Bing Cached 2 URL is: $BingCacheURL2<br>";
$BingCachedSite = file_get_contents($BingCacheURL);
echo $BingCachedSite;
They look the same to me. Not sure what is going on. I would appreciate any help.
Thanks,
Chris