Jump to content

[SOLVED] a little help using preg match


djtozz

Recommended Posts

Hello,

 

Following code is part of a link checker for files hosted on 4shared.com ( it simply checks out of a database with links if a file is still availible or not,  if so... it should grab the "Filename" and "Filesize" and write that in a text file and mysql table.

 

This code has worked before, but 4shared.com made some changes on their downloadpages.

 

Sample url:

http://www.4shared.com/file/102359073/b135d053/Plastik_Funk_-_Rise____Houseshaker_Mix_DRM__.html

 

if($row[2]==5) // 4shared check
{
	$row[1]="http://www.".$row[1];
	$index=getpage($row[1]);
	preg_match("/Download ([^<]+)<\/div>/",$index,$match);
	if(strpos($index,"The file is shared for public access and download.")===false || !$match)
	{
		mysql_query("UPDATE `v2links` SET `checked`='-1',`lastcheck`=NOW() WHERE `id`=".$row[0]);
		print "bad link\n";
		logstr("log-c.txt","bad link\n");
	}
	else
	{
		$words=trim($match[1]);
		$words=preg_split("/[_\.\-\s]/",$words);
		$lastword=array_pop($words);
		$words=implode(" ",$words);
		$words=preg_replace("/\s{2,}/"," ",$words);
		$caption=mysql_real_escape_string($words);
		unset($words);
		unset($match);
		preg_match("/<td>Size\:<\/td><td>([^<]+)<\/td>/",$index,$match);
		$fsize=$match[1];
		unset($match);
		print "$caption :: $fsize\n";
		logstr("log-c.txt","$caption :: $fsize\n");
		mysql_query("UPDATE `v2links` SET `checked`='1',`lastcheck`=NOW(),`fsize`='$fsize',`caption`='$caption' WHERE `id`=".$row[0]);
		if(mysql_errno()) print mysql_error()."\n";
	}
}

 

I undertand that the script isn"t working anymore because following text isn't displayed anymore on their pages:  "The file is shared for public access and download"

 

So I tried to change that into "Kaspersky Anti-Virus" but NO lUCK

 

Can anybody advice me how I could make this working again.

 

Thanks,

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

"Kaspersky Anti-Virus" did the job, I guess I made another typo..

 

and I was able to catch file the file size thanks to an answer in another post.

I used dom to do the job

 

                        $dom = new DOMDocument;
                        @$dom->loadHTML($index);
                        $xpath = new DOMXPath($dom);
                        $tdTag = $xpath->query('//td[@class="finforight"]/text()[contains(.,"KB")]'); // find text belonging to td node that contains the characters KB
                        foreach($tdTag as $val){
                        }

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.