virtuexru Posted January 6, 2009 Share Posted January 6, 2009 I need to read the source of an HTML page and be able to strip one 11 letter/number long key from it. Has to be done through PHP. I'm not so much worried about the stripping of the 11 letter/number but on how to use maybe: fopen To read the file? Quote Link to comment https://forums.phpfreaks.com/topic/139750-php-gurus-how-would-you-go-about-reading-the-source-of-an-html-page/ Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 How indepth do you want to go? file puts the page into an array line by line file_get_contents puts it into a string and works with less code than cURL but is slower. User preference imo. Quote Link to comment https://forums.phpfreaks.com/topic/139750-php-gurus-how-would-you-go-about-reading-the-source-of-an-html-page/#findComment-731146 Share on other sites More sharing options...
virtuexru Posted January 6, 2009 Author Share Posted January 6, 2009 How indepth do you want to go? file puts the page into an array line by line file_get_contents puts it into a string and works with less code than cURL but is slower. User preference imo. I got to show the HTML. Now what I need to do is just strip Line 55: <input type=hidden name=asd value="a490b986af96b1937b9d6ba6796acd11"> I need to strip it so I have a variable as: "a490b986af96b1937b9d6ba6796acd11" Quote Link to comment https://forums.phpfreaks.com/topic/139750-php-gurus-how-would-you-go-about-reading-the-source-of-an-html-page/#findComment-731149 Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 <?php $string = '<input type=hidden name=asd value="a490b986af96b1937b9d6ba6796acd11">'; list(,$string) = split("name=asd value=\"", $string); list($value) = split("\"", $string); echo $value; ?> That would be the easiest. This can be done with regex, but I suck at that so yea. Quote Link to comment https://forums.phpfreaks.com/topic/139750-php-gurus-how-would-you-go-about-reading-the-source-of-an-html-page/#findComment-731150 Share on other sites More sharing options...
DamienRoche Posted January 6, 2009 Share Posted January 6, 2009 this should do it: $string = '<input type=hidden name=asd value="a490b986af96b1937b9d6ba6796acd11">'; preg_match('#name=asd value="(.*?)"#is', $string, $match); echo $match[1]; Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/139750-php-gurus-how-would-you-go-about-reading-the-source-of-an-html-page/#findComment-731165 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.