Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

PHP Search


  • Please log in to reply

#16
Tigger93

Tigger93

    Trusted Helper

  • Topic Starter
  • Retired Staff
  • 1,870 posts
Here's the whole code:

<?php

$url = "http://boards.gamefaqs.com/gfaqs/search.php?board=2000111&search=hjt";
$ch = curl_init();
$timeout = 2; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = @curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == '200') {
$topic = preg_match_all('`http://boards.gamefaqs.com/gfaqs/genmessage.php?board=2000111&topic=(.*)\n?"?`',$content,$matches);
print_r($matches[1]);
}

?>

  • 0

Advertisements


#17
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
When I looked at the source code, http://boards.gamefa...g...0111&topic= could not be found !

But maybe this would help :whistling:
/gfaqs/genmessage.php?board=2000111&amp;topic=
  • 0

#18
Tigger93

Tigger93

    Trusted Helper

  • Topic Starter
  • Retired Staff
  • 1,870 posts
Ah, didn't see that. Just tried it though, same thing... :whistling:

<?php

$url = "http://boards.gamefaqs.com/gfaqs/search.php?board=2000111&search=hjt";
$ch = curl_init();
$timeout = 2; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = @curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == '200') {
$topic = preg_match_all('`http://boards.gamefaqs.com/gfaqs/genmessage.php?board=2000111&amp;topic=(.*)\n?"?`',$content,$matches);
print_r($matches[1]);
}

?>

  • 0

#19
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
<?php

$url = "http://boards.gamefaqs.com/gfaqs/search.php?board=2000111&search=hjt";
$ch = curl_init();
$timeout = 2; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = @curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == '200') {
$topic = preg_match_all('`/gfaqs/genmessage.php\?board=2000111&amp;topic=([0-9]*)`',$content,$matches);
print_r($matches[1]);
}

?>

??

And I changed to [0-9] since I know know that value can only be numbers.

Edited by Michael, 24 April 2007 - 08:38 PM.

  • 0

#20
Tigger93

Tigger93

    Trusted Helper

  • Topic Starter
  • Retired Staff
  • 1,870 posts
Yay! Works now. :whistling: Many thanks for all your help.

Is there anyway though it could make those links and take you to it (to the topic)?
  • 0

#21
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
<?php

$url = "http://boards.gamefaqs.com/gfaqs/search.php?board=2000111&search=hjt";
$ch = curl_init();
$timeout = 2; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = @curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

if($info['http_code'] == '200') {
$topic = preg_match_all('`/gfaqs/genmessage.php\?board=2000111&amp;topic=([0-9]*)`',$content,$matches);
 foreach($matches[0] as $key => $value){
	$label = $matches[1][$key];
	echo("<a href=\"http://boards.gamefaqs.com$value\">$label</a>");
 }
}

?>

:whistling:

EDIT: You may want to make that look nicer.

Edited by Michael, 24 April 2007 - 08:47 PM.

  • 0

#22
Tigger93

Tigger93

    Trusted Helper

  • Topic Starter
  • Retired Staff
  • 1,870 posts
:blink: :help: :help:

Thanks for all the help!! I really appreciate it. :) One last question, anyway to add a space between each link, or put one per line? Sorry for all the requests. :whistling:
  • 0

#23
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
:whistling:

foreach($matches[0] as $key => $value){
$label = $matches[1][$key];
echo("<div><a href=\"http://boards.gamefaqs.com$value\">$label</a></div>");
}


:blink:
  • 0

#24
Tigger93

Tigger93

    Trusted Helper

  • Topic Starter
  • Retired Staff
  • 1,870 posts
Woot! Thanks so much. :whistling:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP