當前位置: 首頁>>代碼示例>>PHP>>正文


PHP scraperWiki::gb_postcode_to_latlng方法代碼示例

本文整理匯總了PHP中scraperWiki::gb_postcode_to_latlng方法的典型用法代碼示例。如果您正苦於以下問題:PHP scraperWiki::gb_postcode_to_latlng方法的具體用法?PHP scraperWiki::gb_postcode_to_latlng怎麽用?PHP scraperWiki::gb_postcode_to_latlng使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scraperWiki的用法示例。


在下文中一共展示了scraperWiki::gb_postcode_to_latlng方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: trim

            $id = trim($cols[0]->find('input', 0)->value);
            $name = trim($cols[0]->find('.resultName', 0)->plaintext);
            $url = html_entity_decode($cols[0]->find('.resultName', 0)->find('a', 0)->href);
            $address = trim($cols[0]->find('.resultAddress', 0)->plaintext);
            $postcode = trim($cols[0]->find('.resultPostcode', 0)->plaintext);
            $stars = sscanf($cols[1]->find('img', 0)->alt, "Food hygiene rating is '%d'");
            //$stars = str_replace("images/scores/", "", $cols[1]->find('img', 0)->src);
            $stars = $stars[0];
            if (!is_numeric($stars)) {
                $stars = "Exempt";
            }
            $premhtml = scraperWiki::scrape($url);
            $premdom = new simple_html_dom();
            $premdom->load($premhtml);
            $businesstype = $premdom->find('h1', 0)->plaintext;
            $date = $premdom->find('#ctl00_ContentPlaceHolder1_uxBusinessLastInspection', 0)->plaintext;
            $address1 = $premdom->find('#ctl00_ContentPlaceHolder1_uxBusinessAddress1', 0)->plaintext;
            $address2 = $premdom->find('#ctl00_ContentPlaceHolder1_uxBusinessAddress2', 0)->plaintext;
            $address3 = $premdom->find('#ctl00_ContentPlaceHolder1_uxBusinessAddress3', 0)->plaintext;
            $address4 = $premdom->find('#ctl00_ContentPlaceHolder1_uxBusinessAddress4', 0)->plaintext;
            $latlng = scraperWiki::gb_postcode_to_latlng($postcode);
            $prem = array('id' => $id, 'name' => html_entity_decode($name), 'address1' => html_entity_decode($address1), 'address2' => html_entity_decode($address2), 'address3' => html_entity_decode($address3), 'address4' => html_entity_decode($address4), 'postcode' => $postcode, 'businesstype' => $businesstype, 'rating' => $stars, 'url' => html_entity_decode($url), 'rssdate' => date("r", strtotime($date)));
            $date = date("c", strtotime($date));
            scraperwiki::save(array('id'), $prem, $date, $latlng);
        }
        # Those pesky form elements again!
        $viewstate = $dom->find('#__VIEWSTATE', 0)->value;
        $eventvalidation = $dom->find('#__EVENTVALIDATION', 0)->value;
        $page++;
    }
}
開發者ID:flyeven,項目名稱:scraperwiki-scraper-vault,代碼行數:31,代碼來源:gwynedd.php


注:本文中的scraperWiki::gb_postcode_to_latlng方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。