extract url function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Abdul202
Forum Newbie
Posts: 3
Joined: Sun Dec 20, 2009 2:17 pm

extract url function

Post by Abdul202 »

i want to creat a script do the following
to extract urls from a page contains any of the following word
rapidshare
megaupload
hotfile
zshare
and whatever else..............
i was trying to make a script to extract all urls and then print only which contain the words that i want
but i couldn't do it i'm a beginner php programer
i'm now tryin to programe it using a diffrent technique
using in_array function
that function will contain few strings because the page which i want to exctat urls from contain just few strings
i want to extract from a page used to protect urls
http://1tool.biz/265677
but i still couldn't achieve what i want
i wrote the following

Code: Select all

 
<?php
// make sure the remote file is successfully opened before doing anything else
$url="http://1tool.biz/265677";
if ($fp = fopen($url, 'r')) {
   $content = '';
   // keep reading until there's nothing left
   while ($line = fgets($fp, 1024)) {
      $content .= $line;
   }
$array_content= explode(" ",$content);// all lines are stored in $array_content
// i want to write a code here to print only text match the following
if (in_array("rapidshare",$array_content))
  {
  echo "the full link <br />";
  }
else
  {
  echo "Match not found<br />";
  }
if (in_array("megaupload",$array_content))
  {
echo "the full link <br />";  }
else
  {
  echo "Match not found<br />";
  }
 
if (in_array(hotfile,$array_content))
  {
echo "the full link <br />";  }
else
  {
  echo "Match not found<br />";
  }
 
} else {
   // an error occured when trying to open the specified url
}
 
 
?>
 
so i convert the all the page into an array so it will using space as a separator because urls shouldn't contain any spaces
but i don't know how to print the full text which contain one of the following strings as an example
rapidshare
megaupload
hotfile
zshare
and whatever else..............
really i'll be very thankful if someone will help me to create such script
thanks in advance..
bhupinder1045
Forum Newbie
Posts: 2
Joined: Tue Feb 02, 2010 8:47 am

Re: extract url function

Post by bhupinder1045 »

Abdul202 wrote:i want to creat a script do the following
to extract urls from a page contains any of the following word
rapidshare
megaupload
hotfile
zshare
and whatever else..............
i was trying to make a script to extract all urls and then print only which contain the words that i want
but i couldn't do it i'm a beginner php programer
i'm now tryin to programe it using a diffrent technique
using in_array function
that function will contain few strings because the page which i want to exctat urls from contain just few strings
i want to extract from a page used to protect urls
http://1tool.biz/265677
but i still couldn't achieve what i want
i wrote the following

Code: Select all

 
<?php
// make sure the remote file is successfully opened before doing anything else
$url="http://1tool.biz/265677";
if ($fp = fopen($url, 'r')) {
   $content = '';
   // keep reading until there's nothing left
   while ($line = fgets($fp, 1024)) {
      $content .= $line;
   }
$array_content= explode(" ",$content);// all lines are stored in $array_content
// i want to write a code here to print only text match the following
if (in_array("rapidshare",$array_content))
  {
  echo "the full link <br />";
  }
else
  {
  echo "Match not found<br />";
  }
if (in_array("megaupload",$array_content))
  {
echo "the full link <br />";  }
else
  {
  echo "Match not found<br />";
  }
 
if (in_array(hotfile,$array_content))
  {
echo "the full link <br />";  }
else
  {
  echo "Match not found<br />";
  }
 
} else {
   // an error occured when trying to open the specified url
}
 
 
?>
 
so i convert the all the page into an array so it will using space as a separator because urls shouldn't contain any spaces
but i don't know how to print the full text which contain one of the following strings as an example
rapidshare
megaupload
hotfile
zshare
and whatever else..............
really i'll be very thankful if someone will help me to create such script
thanks in advance..
Post Reply