我想要使用如何將urlencode包含到源代碼中?
但我不知道如何將我的源。我需要編碼的URL中使用
的file_get_contents
我的代碼:
<script class="ccscript" src="https://code.jquery.com/jquery-3.2.0.min.js" type="text/javascript"></script>
<title>GET URL IMAGE</title>
<div style="width:1265px;margin:auto;">
<?php
if(isset($_POST['ok'])){
$link = $_POST['link'];
$source = file_get_contents($link);
if(strpos($source,'example.org')!==false){
$pa = '#"\s><a\shref=\"(.*?)\".*?>#s';
}else{
$pa = '#<img\sclass.*?src=\"(.*?)\"\/>#s';
}
preg_match_all($pa, $source, $matches);
echo '<div style="float:right"><textarea class="text" cols="110" rows="50">';
foreach($matches[1] as $item) //GET URL 1,IMG TAG = 0
{
if(strpos($item,'http://')!==false)
{
echo $item."\r\n";
}
}
echo '</textarea></div>';
}
?>
<div style="float:left;width:210px;margin-right:15px">
<form action="get.php" method="POST">
<input type="text" name="link" size="60" />
<input type="submit" name="ok" />
</form>
實例網址:http://www.example.org/%E5%9F/
當我試圖讓圖像的URL,我得到此
無法打開流:HTTP請求失敗! HTTP/1.1 503服務暫時無法使用
我想我需要使用進行urlencode這樣我就可以得到圖像的URL
什麼是正確的網址,而不是'HTTP :// www.example.org /%E5%9F /'? – Pharaoh
就像我說的,我需要使用「file_get_contents」,如果我不對URL進行編碼,我無法獲得URL的內容! – Enuma