簡體   English   中英

使用 file_get_content php 獲取搜索結果的內容

[英]get content of search result with file_get_content php

有沒有辦法通過file_get_content獲取搜索結果的內容。 我正在嘗試做這個網站的搜索結果。

http://brillia.com/search/?attribute=1&area=13900,13100,13200,14999,12999,11999

但它沒有給我這部分的內容?attribute=1&area=13900,13100,13200,14999,12999,11999我的函數中是否缺少某些內容。 或者 file_get_content 對此還不夠?

    function pageContent(String $url): \DOMDocument
    {
       $html = cache()->rememberForever($url, function () use ($url) {

           $opts = [
               "http" => [
                   "method" => "GET",
                   "header" => "Accept: text/html\r\n"
               ]
           ];
           $context = stream_context_create($opts);
           $file = file_get_contents($url, false, $context);

           return $file;

       });
       $parser = new \DOMDocument();
       libxml_use_internal_errors(true);

       $parser->loadHTML($html = mb_convert_encoding($html,'HTML-ENTITIES', 'ASCII, JIS, UTF-8, EUC-JP, SJIS'));

       return $parser;
    }
<?php
function pageContent( $url ) {
    header('Content-type: text/html; charset=EUC-JP');
    echo '<base href="http://brillia.com">';
    echo file_get_contents($url);
}

echo pageContent('http://brillia.com/search/?attribute=1&area=13900,13100,13200,14999,12999,11999');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM