php
1<?php 2/*Webスクレイピングの質問です. 3下記のソースコードにURLを入力するとサイトからタグを拾ってくるというものを作りました。ソースコードを拾ってきたのですが、HTMLにデータがとんできません。どこが間違ってますか? 4*/ 5include("simple_html_dom.php"); 6$url = "ここにURL"; 7$dom = file_get_html($url); 8$elem01 = $dom->find("#expert", 0)->find(".inner",0)->find("table",0); 9} 10 11?> 12
HTML
1<!DOCTYPE html> 2<html> 3<head> 4<title></title> 5<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script> 6<script src="123.php"></script> 7<script> 8$(document).ready(function(){ 9 $("#btn").click(function(){ 10 $("#output").html(""); 11 $.ajax({url:url, dataType:"json", cache:false, success:function(j){ 12 $.each(j["list"], function(i){ 13 14 if(this.title.indexOf($("#key").val()) != -1){ 15 var src = (this.url) ? "<div>" + this.date + ":" + this.title + "<a href='" + this.url + "' target='_blank'>表示</a></div><hr>" : "<div>" + this.date + ":" + this.title + "</div><hr>"; 16 $("#output").append(src); 17 } 18 }); 19 }}).fail(function(res){ 20 $("#output").html(res.responseText); 21 }); 22 }); 23}); 24</script> 25</head> 26<body> 27検索キーワード<input type="text" id="key"><br> 28<input type="button" value="検索" id="btn"> 29<div id="output"></div> 30</body> 31</html> 32
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。