DJphp Posted November 20, 2007 Share Posted November 20, 2007 Hi, I would like to display/capture/use the URL's that are displayed on a web page after making a query to a forum. What do I mean? I am part of a forum that uses vBulletin. One option is to display the forum topics that have had posts that day, i.e. active topics. Essentially, when you click on the link: http://www.somedomain.com/forum/search.php?do=getdaily the resultant page has a list of the active topics, highlighted as links. What i would like to do is capture/access that resultant page and use regular expressions to grab the URLs. I can do the RegEx but I cannot seem to capture that resultant page. is it possible with php? any help is appreciated. cheers, DJphp Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/ Share on other sites More sharing options...
MadTechie Posted November 20, 2007 Share Posted November 20, 2007 I think i know what you mean.. are you trying to extract the FULL URL ? Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395157 Share on other sites More sharing options...
DJphp Posted November 20, 2007 Author Share Posted November 20, 2007 thanks for your reply. The page returned has similar entries to following in the source code: <a href="showthread.php?t=12345" id="thread_title_12345" style="font-weight:bold">Title of article</a> I need to grab the "showthread.php?t=12345", although I can do that with regexp, and I can add the rest of the URL, e.g. http://www.somdomain.com/.... unfortunately, I cannot grab the page as the "http://www.somedomain.com/forum/search.php?do=getdaily" link returns the page I need as a result of the search. cheers Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395438 Share on other sites More sharing options...
MadTechie Posted November 20, 2007 Share Posted November 20, 2007 to grab that try this <?php $html = 'unfortunately, I cannot grab the page as the "http://www.somedomain.com/forum/search.php?do=getdaily" link returns the page I need as a result of the search.'; $found = ""; if (preg_match('/(https?:\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/si', $html, $regs)) { $found= $regs[0]; } echo $found; ?> Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395471 Share on other sites More sharing options...
DJphp Posted November 20, 2007 Author Share Posted November 20, 2007 to grab that try this <?php $html = 'unfortunately, I cannot grab the page as the "http://www.somedomain.com/forum/search.php?do=getdaily" link returns the page I need as a result of the search.'; $found = ""; if (preg_match('/(https?:\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/si', $html, $regs)) { $found= $regs[0]; } echo $found; ?> Thanks for the reply. I am not sure that I was clear enough in my description- always a struggle for me! When I click on the link: http://www.somedomain.com/forum/search.php?do=getdaily this runs a server script that generates and returns a whole new page that includes the titles and URL's of all of the day's posts to the forum. What I need to do is send to the server from my own php the request for the results, i.e. access http://www.somedomain.com/forum/search.php?do=getdaily but then grab the contents of the resultant page and do some regexp matching. Actually, the same process would be seen if you click on "Show unread posts since last visit. " in this (phpfreaks) forum. cheers, DJphp Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395503 Share on other sites More sharing options...
MadTechie Posted November 20, 2007 Share Posted November 20, 2007 Ahhhh.. scrapping.. have you tried file_get_contents ie <?php $data = file_get_contents("http://www.google.com"); echo str_replace("Lucky","Unlucky",$data); ?> if you need more control your need to use cURL or fSockets Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395507 Share on other sites More sharing options...
DJphp Posted November 20, 2007 Author Share Posted November 20, 2007 Ahhhh.. scrapping.. have you tried file_get_contents that is it exactly!! Thanks. and thanks for the reminder about cURL- i was thinking about libcurl, as well, but: - could not remember what it was called - thought there must be a way with php, without using libcurl now I can try to work on it from there. thanks for your help. DJphp Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395513 Share on other sites More sharing options...
MadTechie Posted November 20, 2007 Share Posted November 20, 2007 well when your done.. remember to click solved bottom left Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395515 Share on other sites More sharing options...
DJphp Posted November 21, 2007 Author Share Posted November 21, 2007 thanks for your help! will close this topic. Quote Link to comment https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/#findComment-395539 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.