Ejemplo n.º 1
0
 public function HTMLGetTitle($html, $url, $outputMode = self::XML_OUTPUT_MODE, $textParams = null)
 {
     $this->CheckHTML($html, $url, $outputMode);
     $this->CheckParamType("AlchemyAPI_TextParams", $textParams);
     if (is_null($textParams)) {
         $textParams = new AlchemyAPI_TextParams();
     }
     $textParams->setHtml($html);
     $textParams->setUrl($url);
     $textParams->setOutputMode($outputMode);
     return $this->POST("HTMLGetTitle", "html", $textParams);
 }
Ejemplo n.º 2
0
function CheckTextParams()
{
    $alchemyObj = new AlchemyAPI();
    $alchemyObj->loadAPIKey("api_key.txt");
    $htmlFile = file_get_contents("../example/data/example.html");
    $htmlFile2 = file_get_contents("../example/data/example2.html");
    $htmlFile2_nolinks = file_get_contents("../example/data/example2_nolinks.html");
    $textParams = new AlchemyAPI_TextParams();
    $result = $alchemyObj->HTMLGetText($htmlFile2, "http://www.test.com/", "xml", $textParams);
    $doc = simplexml_load_string($result);
    CheckForOKStatus($result);
    $matches = $doc->xpath("//a");
    assert(count($matches) == 0);
    $textParams = new AlchemyAPI_TextParams();
    $textParams->setExtractLinks(1);
    $result = $alchemyObj->HTMLGetText($htmlFile2, "http://www.test.com/", "xml", $textParams);
    $doc = simplexml_load_string($result);
    CheckForOKStatus($result);
}