�ǽ�Ϥ���������Ƥ�������ɡ����ȤäƤ�Τϣ��ѥ�����
�٥���ޡ����Ȥäƺ�®���ä�����Ȥ�����ʤ���ñ�˴��줫�⡣
scrape_func.php
���Υ��饤�꡼���ܤΥ���ץ륳���ɤ˴ޤޤ�Ƥ���ե����롣http://www.oreilly.co.jp/books/4873111870/download.html
�����Ƚ����񤤤�ľ��Ū�˼�äƤ���롣
$_rawData = getURL($url); $_rawData = mb_convert_encoding($_rawData, "UTF-8", "auto"); $_rawData = cleanString( $_rawData ); $headline = getBlock("<div id=\"headline\">","</div>",$_rawData,false); $title = getElement("h1", $_rawData);
XPATH
xpath�Ȥ��Τ�����Ū���Ȥϻפ����ɡ����ä��㤤�������Ⱦ�˵󤲤��饤�֥��������ᤤ�����͡��Ǥ����˸¤餺�Ȥ��뤫��������
���Υ֥����Υ����ȥ����㡣
$res = file_get_contents($url); $dom = @DOMDocument::loadHTML($res); $xml = simplexml_import_dom($dom); //�ǿ������Υ����ȥ� $title = $xml->xpath("//div[@class='hentry']/h2/a/text()"); echo (string) current($title); //3���ܤε����Υ����ȥ� $title = $xml->xpath("//div[@class='hentry'][3]/h2/a/text()"); echo (string) current($title); //3���ܤε����Υ�� $link = $xml->xpath("//div[@class='hentry'][3]/h2/a/@href")
�����쥤�ԥ󥰤ä���ƻ�ʺ�Ȥ���͡�
�ƥ����Ȥ��Ȥˤܼۤ�ư�б�����