Page 5 of 8

Re: Php link exporter

Posted: Sat Nov 28, 2009 6:40 am
by The_L
Hmm it still does not list anything...

Code: Select all

$search = 'http://rapidshare.com/'; // matches *.rapidshare.com/
Can i insert an array here like

Code: Select all

$search = array("http://rapidshare.com", "http://www.rapidshare.com", "www.rapidshare.com");

Re: Php link exporter

Posted: Sat Nov 28, 2009 6:55 am
by iankent
The_L wrote:Hmm it still does not list anything...

Code: Select all

$search = 'http://rapidshare.com/'; // matches *.rapidshare.com/
Can i insert an array here like

Code: Select all

$search = array("http://rapidshare.com", "http://www.rapidshare.com", "www.rapidshare.com");
If you comment out the lines I suggested earlier (the if(strpos($search, $link)) line and its corresponding closing bracket) what result do you get? Without those lines you can manually check the list to make sure it does contain rapidshare links.

To use an array you just need to add another loop inside your existing ones, e.g.

Code: Select all

echo "<h2>Links present on page: ".$urlrun."</h2><br />";
// Loop to pump out the results
echo "<ul>";
// create an array of terms to find
$search = array('.rapidshare.com','http://rapidshare.com');
foreach ($linkarray as $links) {
    foreach($links as $link) {
        // loop through the search terms wit ha foreach
        foreach($search as $search_term) {
            // Comment out the next line to manually check the results
            if(strpos($link, $search_term) > -1) { // Now matching $search_term instead of $search
            // Leave the next line here
                 echo "<li>$link<li>";
            // And comment out the next line
            }
        }
    }
}
echo "</ul>";

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:00 am
by The_L
Ok there is something wrong...i commented this line:

Code: Select all

$search = 'http://rapidshare.com/'; // matches *.rapidshare.com/
And it does not list anything...:/

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:07 am
by iankent
The_L wrote:Ok there is something wrong...i commented this line:

Code: Select all

$search = 'http://rapidshare.com/'; // matches *.rapidshare.com/
And it does not list anything...:/
Why have you commented that line out? You need to comment out the strpos line and its closing bracket, leaving the echo "<li>$link</li>" bit as it is. Everything else stays the same.

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:15 am
by The_L

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 = 'http://rapidshare.com/'; // matches *.rapidshare.com/
foreach ($linkarray as $links) {
    foreach($links as $link) {
                // if(strpos($link, $search) > -1) {
                    echo "<li>$link<li>";
                // }
    }
}
echo "</ul>";
exit;
There...it still doesnot show anything...

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:25 am
by iankent
Please show the full code again, if its not displaying anything then its likely something at the top has changed something

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:38 am
by The_L

Code: Select all

<?php
 
//Make a title spider
$tspider = new tagSpider();
 
//Pass URL to the fetch page function
$tspider->fetchPage($urlrun);
 
// input box
$urlrun = $_POST['urlrun'];
if (!$urlrun) die("<form method='post'><input type='text' name='urlrun'> <input type='submit'></form>");
 
// Enter the tags into the parse array function
$linkarray = $tspider->parse_array();
 
echo "<h2>Links present on page: ".$urlrun."</h2><br />";
// Loop to pump out the results
echo "<ul>";
$search = 'http://rapidshare.com/'; // matches *.rapidshare.com/
foreach ($linkarray as $links) {
    foreach($links as $link) {
                // if(strpos($link, $search) > -1) {
                    echo "<li>$link<li>";
                // }
    }
}
echo "</ul>";
exit;
Here is the whole file..
taggrab.rar

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:42 am
by iankent
This bit needs to change

Code: Select all

//Pass URL to the fetch page function
$tspider->fetchPage($urlrun);
 
// input box
$urlrun = $_POST['urlrun'];
if (!$urlrun) die("<form method='post'><input type='text' name='urlrun'> <input type='submit'></form>");
Needs to be the other way around - you have to set $urlrun before you can pass it to fetchPage($urlrun)

Re: Php link exporter

Posted: Sat Nov 28, 2009 7:48 am
by The_L
That makes sence... i done what you told and it listed all links...so i uncommented the codes and its perfect,lists just rapidshare links =))))

Re: Php link exporter

Posted: Sat Nov 28, 2009 8:03 am
by The_L
How can i put the list in <table>? And how to remove those dots per line (in link listing)? So i can middle it and add some graphics...

Re: Php link exporter

Posted: Sat Nov 28, 2009 8:10 am
by iankent
The_L wrote:How can i put the list in <table>? And how to remove those dots per line (in link listing)? So i can middle it and add some graphics...
Replace the <ul> and </ul> tags with <table> and </table> tags. If you want a header row, add something like this straight after the opening <table> tag:

Code: Select all

echo "<tr>
    <th>Col1</th>
    <th>Col2</th>
</tr>";
Then, inside the loop where you currently use echo "<li>$link</li>";, use something like this:

Code: Select all

echo "<tr>
    <td>$link</td>
    <td>something else</td>
</tr>";
That should output each link in its own table row. The <th> ones are table headers, and <td> are table cells.

Re: Php link exporter

Posted: Sat Nov 28, 2009 9:20 am
by The_L

Code: Select all

echo "<table align="center">";
$search = 'http://rapidshare.com/'; // matches *.rapidshare.com/
foreach ($linkarray as $links) {
    foreach($links as $link) {
                 if(strpos($link, $search) > -1) {
echo "<tr>
    <td>$link</td>
</tr>";
                 }
    }
}
echo "</table>";
exit;
What is wrong here??

Re: Php link exporter

Posted: Sat Nov 28, 2009 9:32 am
by iankent
The_L wrote:What is wrong here??
You need to escape the "s in the first line, otherwise PHP thinks the string has ended after align=

Code: Select all

echo "<table align=\"center\">";

Re: Php link exporter

Posted: Sat Nov 28, 2009 11:27 am
by The_L
aha..done but again something is wrong..there are two lists one below another...it double-listed the links :D

Re: Php link exporter

Posted: Sat Nov 28, 2009 11:37 am
by iankent
The_L wrote:aha..done but again something is wrong..there are two lists one below another...it double-listed the links :D
Change your parse_array function so it returns $matching_data[0] instead, i.e.

Code: Select all

 
    return $matching_data[0];
 
Then update your main code file to remove the inner foreach loop and rename the outer foreach variable to $link, e.g.

Code: Select all

foreach ($linkarray as $links) {
    if(strpos($link, $search) > -1) {
        echo "<tr>
            <td>$link</td>
            </tr>";
    }
}
my fault sorry, preg_match_all returns an array containing two lists, and we only need the first one