Bikkebakke Posted June 2, 2010 Share Posted June 2, 2010 Hello again, Freaks! I stumbled upon a rather tedious problem that I've been trying to solve for quite some time now. I play this browser-game which includes a lot of clicking so I made a menu (simple page that consists of two frames, one for the menu and one for the game itself) that holds links and forms to lessen the clicking on the actual game. Now I've been trying to find a way to echo my characters HP etc. from the games profile-page to the menu but I can't access my profile-page with file_get_contents();, because it's required to be logged in to see the page. So, after burying that idea I got a new one: Loading the profile page inside the menu frame as a hidden div that reloads every now and then, but I don't know how to find and echo the parts of text I want to, so if anyone could help me on how to echo a certain part of text on the same page the code is ran? Sorry if I was confusing, feel free to ask for more details if needed, - Bikkebakke Quote Link to comment https://forums.phpfreaks.com/topic/203628-echoing-a-certain-part-of-a-text-held-inside-a-div/ Share on other sites More sharing options...
Adam Posted June 2, 2010 Share Posted June 2, 2010 Look into cURL. Then you'll probably want to use DOMDocument or a regular expression to parse the data you need. Quote Link to comment https://forums.phpfreaks.com/topic/203628-echoing-a-certain-part-of-a-text-held-inside-a-div/#findComment-1066610 Share on other sites More sharing options...
Bikkebakke Posted June 2, 2010 Author Share Posted June 2, 2010 I really doubt I need that advanced stuff, all I need to do is pick a part of text, the first method I tried was: <?php $contents = file_get_contents('http://www.example.com'); $term_search="Search_term"; $no_term=1000; $pos=strpos($contents, $term_search); $pos += strlen($term_search); $new_pos = substr($contents,$pos,$no_term); echo $new_pos; ?> But as of now I don't get the content from another location but from the very same file. So like, is there a way to find text from the same file? I.e. <html-stuff> <div that loads an page in it> <more html-stuff> <?php //$fetch = script to fetch the contents of the previously mentioned <div> echo $fetch; ?> Quote Link to comment https://forums.phpfreaks.com/topic/203628-echoing-a-certain-part-of-a-text-held-inside-a-div/#findComment-1066619 Share on other sites More sharing options...
Bikkebakke Posted June 2, 2010 Author Share Posted June 2, 2010 Or could this be easier to do in Javascript/AJAX instead of PHP? Quote Link to comment https://forums.phpfreaks.com/topic/203628-echoing-a-certain-part-of-a-text-held-inside-a-div/#findComment-1066627 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.