Page 4 of 8

Re: Php link exporter

Posted: Fri Nov 27, 2009 1:37 am
by iankent
The_L wrote:can you just make it work and attach it?
I have, and this is the last time I'll be repeating myself (this is now the fourth time I've mentioned it).

Look back a few posts, there's an attachment, the file inside WORKS. I've tested it. If you get any errors using THAT file, post them here.

Re: Php link exporter

Posted: Fri Nov 27, 2009 2:32 am
by The_L
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /nfs/c02/h10/mnt/30579/domains/forum-racunara.com/html/test/taggrab.php on line 64

Warning: file_get_contents(http://www.google.co.uk/search?q=test) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /nfs/c02/h10/mnt/30579/domains/forum-racunara.com/html/test/taggrab.php on line 64

Re: Php link exporter

Posted: Fri Nov 27, 2009 5:37 am
by iankent
Its a problem with file_get_contents. If you look in the source code i've commented out your CURL lines and added my own file_get_contents. Delete my line and uncomment your CURL lines and it should work.

Re: Php link exporter

Posted: Fri Nov 27, 2009 5:43 am
by The_L
It works but i can't understand anything...this are exported links???

Re: Php link exporter

Posted: Fri Nov 27, 2009 6:33 am
by iankent
Not sure what you mean, definately looks like a list of links to me. As i said, there are some false positives which you may want to filter out, but thats returning pretty much everything that could be a link.

From what i can see its now doing what you wanted your original code to do?

Re: Php link exporter

Posted: Fri Nov 27, 2009 4:07 pm
by The_L
Okay now that that is done,how can i filter it to search and export just like rapidshare links...

Re: Php link exporter

Posted: Fri Nov 27, 2009 4:37 pm
by iankent
The_L wrote:Okay now that that is done,how can i filter it to search and export just like rapidshare links...
two ways - loop through with a simple string match, or loop through and apply a regex. there are other ways but these are easiest. An example of a simple string match, assuming all of the links are stored in $linkarray:

Code: Select all

 
$newarray = array();
$search = '.rapidshare.com/'; // matches *.rapidshare.com/
foreach($linkarray as $link) {
    if(strpos($link, $search)) {
        $newarray[] = $link;
    }
}
// $newarray contains results
 

Re: Php link exporter

Posted: Fri Nov 27, 2009 5:08 pm
by The_L
To insert this in same php file or to make a new one??

Re: Php link exporter

Posted: Fri Nov 27, 2009 5:18 pm
by iankent
The_L wrote:To insert this in same php file or to make a new one??
In the same file - somewhere after this line:

Code: Select all

$linkarray = $tspider->parse_array();
You could do it as part of the loop thats outputting the display. Instead of creating a new array and copying the links to it, you could run the if statement in your existing loop and only output if it matches, e.g.

Code: Select all

echo "<h2>Links present on page: ".$urlrun."</h2><br />";
// Loop to pump out the results
echo "<ul>";
$search = '.rapidshare.com/'; // matches *.rapidshare.com/
foreach ($linkarray as $links) {
    foreach($links as $link) {
                if(strpos($link, $search) > -1) {
                    echo "<li>$link<li>";
                }
    }
}
echo "</ul>";

Re: Php link exporter

Posted: Fri Nov 27, 2009 5:34 pm
by The_L
Now it does not export anything...
May i add this part of code cause i rly dont understand what is http://www.google.co.uk/search?q=test:

Code: Select all

$urlrun = $_POST['urlrun'];
if (!$urlrun) die("<form method='post'><input type='text' name='urlrun'> <input type='submit'></form>");

here is that part of code maybe i did it wrong...

Code: Select all

$linkarray = $tspider->parse_array();
 
echo "<h2>Links present on page: ".$urlrun."</h2><br />";
// Loop to pump out the results
echo "<ul>";
$search = '.rapidshare.com/'; // matches *.rapidshare.com/
foreach ($linkarray as $links) {
    foreach($links as $link) {
          if(strpos($link, $search) > -1) {
        echo "<li>$link<li>";
    }
}
}
echo "</ul>";

Re: Php link exporter

Posted: Fri Nov 27, 2009 5:49 pm
by iankent
The code you've added at the top should be fine (if a little odd, probably better to use an if statement and exit to stop the script - on some servers, die() goes to error log instead of output)

The second bit does look right, but to test it try commenting out the if lines (i.e. 9 and 11 in the last bit of code you posted). Check the results you get to make sure its finding some matching rapidshare.com and we'll go from there. Its possible that either the page you're getting doesn't contain rapidshare links, the regex isn't working quite right, or the strpos bit isn't working, so temporarily disabling the lines above will hopefully narrow it down!

Re: Php link exporter

Posted: Fri Nov 27, 2009 6:12 pm
by The_L
Fatal error: Call to a member function parse_array() on a non-object in /nfs/c02/h10/mnt/30579/domains/forum-racunara.com/html/test/taggrab.php on line 19
I just added the code and comment these lines:

Code: Select all

 
$tspider = new tagSpider();
$tspider->fetchPage($urlrun);

Re: Php link exporter

Posted: Fri Nov 27, 2009 6:20 pm
by iankent
The_L wrote:I just added the code and comment these lines:

Code: Select all

 
$tspider = new tagSpider();
$tspider->fetchPage($urlrun);
Why did you comment out those lines?

I mentioned line 9 and 11 in your code sample not in your actual file, i.e.

Code: Select all

echo "<h2>Links present on page: ".$urlrun."</h2><br />";
// Loop to pump out the results
echo "<ul>";
$search = '.rapidshare.com/'; // matches *.rapidshare.com/
foreach ($linkarray as $links) {
    foreach($links as $link) {
                // if(strpos($link, $search) > -1) {
                    echo "<li>$link<li>";
                // }
    }
}
echo "</ul>";
everything else should stay as it was :) that simply disables the actual string checking so you can manually check the results to make sure they definately include rapidshare URLs

Re: Php link exporter

Posted: Fri Nov 27, 2009 6:49 pm
by The_L
How there are no errors but also no results..does this code:

Code: Select all

$search = '.rapidshare.com/'; // matches *.rapidshare.com/
searches "http://rapidshare.com" also or just ".rapidshare.com/"??? O.o
Yep i am sure that there are rapidshare links on the page...

Re: Php link exporter

Posted: Sat Nov 28, 2009 5:07 am
by iankent
The_L wrote:How there are no errors but also no results..does this code:

Code: Select all

$search = '.rapidshare.com/'; // matches *.rapidshare.com/
searches "http://rapidshare.com" also or just ".rapidshare.com/"??? O.o
Yep i am sure that there are rapidshare links on the page...
Good point, just .rapidshare.com, so you may want to remove the leading .

It's a preventative to make sure you don't match something like http://somedodgyrapidshare.com/, but it does mean you don't match http://rapidshare.com/

change it as you see fit :)