Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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