npsari Posted May 10, 2008 Share Posted May 10, 2008 Hi there, I have a page which is full of HTML codes the page URL is /bulk/twister/ In the middle of the codes, there is this bit <td class="text" width="70" height="70" bgcolor="#ffffff" > <a id="reget_url" href="/users/"><img border="0" alt="" src="/images/user/5676.jpg" /></a> <td> I want to get the image src out of all the mess in the page So, what i done is, step 1. I include the page first (Which i am not sure if it is correct, because the HTMl is not disabled) <?php include "../bulk/twister/"; ?> Then, i dont know the script which will get the image src Can't i use the reget_url part? (which as you can see above, it stays the same) Your help will be amazing Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/ Share on other sites More sharing options...
rarebit Posted May 10, 2008 Share Posted May 10, 2008 Is there only 1 image? e.g search for position of '<img', then starting from there search for '>', then extract... p.s. you prolly dont actually want to include the page but just open & read it... *** alternative is to use regex! Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537608 Share on other sites More sharing options...
npsari Posted May 10, 2008 Author Share Posted May 10, 2008 Actually, no, you are correct, there are more than one <img Now a realized that /users/ is the same always, and it is the first one to occur in the page Can you tell me how can i make the script to pick between /users/ to <td> i.e., this part: <img border="0" alt="" src="/images/user/5676.jpg" /></a> And I will then take it from there Ohh, and how do i read the page without including it :-\ Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537616 Share on other sites More sharing options...
rarebit Posted May 10, 2008 Share Posted May 10, 2008 Can you tell me how can i make the script to pick between /users/ to <td> You just did! Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537627 Share on other sites More sharing options...
npsari Posted May 10, 2008 Author Share Posted May 10, 2008 Well, i think i was wondering how can i get /users/ to be the search term but actually, i can do that myself I just need a way to read the page now and may i mention, that this page is an external page which is not hosted in my server It is from a different website I checked this link out, but it talks about reading text files only http://php.about.com/od/advancedphp/ss/php_read_file.htm Not how to read a webpage any hints on that Perhaps i can put it include it in a text area, then submit the text area print"<textarea>"; include "http://www.example.com"; print"</textarea>"; That should do it i guess Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537631 Share on other sites More sharing options...
thebadbad Posted May 10, 2008 Share Posted May 10, 2008 <?php $string = file_get_contents('http://putyourlinkhere.com/'); preg_match('|<a id="reget_url" href="/users/"><img border="0" alt="" src="(.*?)" /></a>|is', $string, $matches); echo $matches[1]; ?> Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537635 Share on other sites More sharing options...
npsari Posted May 10, 2008 Author Share Posted May 10, 2008 I am working on your code Somehow, it is not giving me any results I wonder why I am trying to work it out Thank you guys for the help Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537642 Share on other sites More sharing options...
rarebit Posted May 10, 2008 Share Posted May 10, 2008 If it's external you may want to look at cURL to get the page... Link to comment https://forums.phpfreaks.com/topic/105029-a-mind-challenging-question-or-is-it/#findComment-537643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.