Jump to content
php.lv forumi

Teksti no citas lapas


Artenis

Recommended Posts

Sveiki!

Varbūt kādam ir kāds normāls risinājums, kā savākt no kādas lapas informāciju? Piemēram konkrētas <div> klases tekstu?

Meklējot atradu tādu screen Scraping tik īsti cik skatījos nebija tas, kas vajadzīgs, bet varbūt tomēr?

Paldies.

Link to comment
Share on other sites

Requirements: PHP 5+

$Url = "http://php.lv/index.php";

$Handle = @fopen($Url, "rb");
$Contents = stream_get_contents($Handle);
fclose($Handle);


$klase = "ipb-top-left-link";
$RegExCode = ".*<div.*class=\"$klase\">(.*)</div>";
preg_match($RegExCode, $Contents, $results);
print_r($results);

 

Nomaini $Url, $RegExCode

Kaut kam tādam vajadzētu strādāt. Ja nestrādā, tad pielabo skatoties php.net dokumentāciju :]

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...