curl, crowbar...passing to jquery
<?php
function get_html($url)
{
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, 'http://127.0.0.1:10000/?url=' . $url . '&delay=3000&view=as-is');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec ($curl);
return $html;
}
?>
Im using this php code to access the html using crowbar...my question is, how would I pass the html to jquery for some processing (scraping).
My jquery starts with the document.ready(function(), would this work since crowbar actually loads the DOM in a browser?
This is some of my jquery code:
$(document).ready(function(){
var title = $('title').text();
$.ajax({
type: "POST",
url: "tosql.php",
data: {title:title}
});
});
Im only get开发者_高级运维ting the title (for test purposes) because I pass this to php to be stored in mysql
Yes, jQuery can manipulate everything in the DOM after it loads via the document.ready wrapper. If you need easier manipulation, have crowbar render data as an object or array inside of <script>
tags. If you have more code to show I can give a more complete answer.
精彩评论