rascle Posted July 25, 2010 Share Posted July 25, 2010 Hi I have been looking at the tutorials on W3 Schools about file open but I havent been able to find what I want. I am trying to make some code that connects to a website (I can do that part) and search through the page until It reaches a specified piece of text, it would then change that code and save the file. Does anyone know how I could do this?? Thanks Rhys Link to comment https://forums.phpfreaks.com/topic/208850-using-file-open/ Share on other sites More sharing options...
AbraCadaver Posted July 25, 2010 Share Posted July 25, 2010 Hi I have been looking at the tutorials on W3 Schools about file open but I havent been able to find what I want. I am trying to make some code that connects to a website (I can do that part) and search through the page until It reaches a specified piece of text, it would then change that code and save the file. Does anyone know how I could do this?? Thanks Rhys file_put_contents('/path/to/file/to/save.html', str_replace('text to replace', 'replacement text', file_get_contents('http://example.com/page.html')); Link to comment https://forums.phpfreaks.com/topic/208850-using-file-open/#findComment-1090954 Share on other sites More sharing options...
rascle Posted July 25, 2010 Author Share Posted July 25, 2010 Thanks However I get a reply "Parse error: syntax error, unexpected ';' in /home/b25rasc/public_html/test.php on line 22" Also what does "file_get_contents('http://example.com/page.html'));" do?? Should I put the target web address there? Thanks Link to comment https://forums.phpfreaks.com/topic/208850-using-file-open/#findComment-1090957 Share on other sites More sharing options...
AbraCadaver Posted July 25, 2010 Share Posted July 25, 2010 Sorry, forgot a closing ), and yes replace with the URL you want. file_put_contents('/path/to/file/to/save.html', str_replace('text to replace', 'replacement text', file_get_contents('http://example.com/page.html'))); Link to comment https://forums.phpfreaks.com/topic/208850-using-file-open/#findComment-1090961 Share on other sites More sharing options...
rascle Posted July 25, 2010 Author Share Posted July 25, 2010 Thanks a lot Link to comment https://forums.phpfreaks.com/topic/208850-using-file-open/#findComment-1090962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.