Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/78041-solved-capturingusing-results-of-query/
Share on other sites

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

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;

?>

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

 

 

 

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

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.