vividona Posted December 8, 2011 Share Posted December 8, 2011 eg http://www.xxxxxxx.com/index.php?action=viewarti&artid=5 How can I write the content of this link into file. Quote Link to comment https://forums.phpfreaks.com/topic/252745-write-url-contents-into-file/ Share on other sites More sharing options...
freelance84 Posted December 8, 2011 Share Posted December 8, 2011 http://bit.ly/tolTMm sorry i just love LMGTFY... however there are litereally hundreds of guides out there on this. try phpclasses for a premade script to rip sections out you require from a html page if you require Quote Link to comment https://forums.phpfreaks.com/topic/252745-write-url-contents-into-file/#findComment-1295733 Share on other sites More sharing options...
Adam Posted December 8, 2011 Share Posted December 8, 2011 file_get_contents file_put_contents Quote Link to comment https://forums.phpfreaks.com/topic/252745-write-url-contents-into-file/#findComment-1295734 Share on other sites More sharing options...
vividona Posted December 8, 2011 Author Share Posted December 8, 2011 file_get_contents file_put_contents I tried those functions. But they did not accept links in localhost http://localhost/xxxxx/index.php?action=viewarti&artid=5 Quote Link to comment https://forums.phpfreaks.com/topic/252745-write-url-contents-into-file/#findComment-1295792 Share on other sites More sharing options...
The Little Guy Posted December 8, 2011 Share Posted December 8, 2011 cURL and file: $url = "http://someurl.com/something"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETRUNTRANSFER, ture); curl_setopt($ch, CURLOPT_BINARYTRANSFER, ture); $opt = curl_exec($ch); $handle = fopen("myfile.txt", "wb"); fwrite($handle, $opt); fclose($handle); Quote Link to comment https://forums.phpfreaks.com/topic/252745-write-url-contents-into-file/#findComment-1295811 Share on other sites More sharing options...
btellez Posted December 8, 2011 Share Posted December 8, 2011 When your script goes live(which i assume it will) you wont be using a localhost address....To test the part you write that writes the contents to a file you can use almost any url, or place a sample file file on a server, for sakes of testing you can use "http://www.phpfreaks.com/forums/index.php?board=1.0" and if the HTML from the page gets written to your file, then it will almost certainly work with other URL's you specify.... Or look into configuring virtual host on your local apache install. Quote Link to comment https://forums.phpfreaks.com/topic/252745-write-url-contents-into-file/#findComment-1295819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.