扩展名中未显示任何输出

时间:2018-10-03 09:32:14

标签: javascript php html5 machine-learning google-chrome-extension

我被困在我想使用机器学习检测网络钓鱼网站的项目中。我有扩展程序,但是没有显示输出。我正在使用Windows操作系统。

clientServer.php

<?php
header("Access-Control-Allow-Origin: *");
$site=$_POST['url'];
$html = file_get_contents($site);
echo $html;
$bytes=file_put_contents('markup.txt', $html);
//$a=exec('/usr/bin/python /opt/lampp/htdocs/BE/test.py '.$site.' 2>&1 ');
$a=exec('/wamp64/www/test.py 2>&1'  ,$site);
echo $a;
?>

popup.js

function transfer(){    
    var tablink;
    chrome.tabs.getSelected(null,function(tab) {
        tablink = tab.url;
        //alert(tablink);
        $("#p1").text("The URL being tested is - "+tablink);

    var xhr=new XMLHttpRequest();
    //alert("hii");
    //var tablink='';   
    //var safe = document.URL;
    params="url="+tablink;
    alert(params);
    var markup = "url="+tablink+"&html="+document.documentElement.innerHTML;
    xhr.open("POST","http://localhost/clientServer.php", true);
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr.send(markup);
    alert(xhr.responseText);
    $("#div1").text(xhr.responseText);  
    return xhr.responseText;
    /*if(xhr.responseText==6)
    {
        return "safe";
    }
    return "nooooo";*/
    });
}


$(document).ready(function(){
    $("button").click(function(){   
    var val = transfer();
//  $("#p1").text(val);
        });
});

chrome.tabs.getSelected(null,function(tab) {
    var tablink = tab.url;
    $("#p1").text("The URL being tested is - "+tablink);
});

popup.html

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="popup.js" type = "text/javascript"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>

<div><h2> Check your WebPage </h2></div>
<div id = "p1"></div>
<p>Find out now...<br><sup>&darr;</sup></p>
<div><button class="button" ><span>Safe or No?</span></button>
<div id="div1"></div>
</div>
</body>
</html>

我已将clientServer.php放在wamp的www文件夹中,还将test.py放在wamp文件夹中,这是我的python文件。

查看扩展名,当我单击“安全/不”按钮时,它不显示任何内容 enter image description here

0 个答案:

没有答案