C#页面navi PHP抓取

时间:2019-04-27 14:02:34

标签: c# php web-scraping

我尝试抓取此页面: http://eshop.saphokft.hu/shop/Productslist.aspx?CategoryCode=sprchove-zasteny

我尝试使用PHP cURL从navi加载9.页面,但是我无法正常工作。

我只能刮1-8页,但是我不能从8页跳到9页。

出什么问题了?我尝试使用phantomJs和简单的PHP cURL。

function downloadUrl($url){
    //$content = 'error';
    $client = Client::getInstance();
    //$p = explode(':', $proxy);
    //$Proxy = $p[0];
    //$proxyPort = $p[0];
    //$client->getEngine()->addOption("--proxy=176.61.143.43:80");
    //$client->getEngine()->addOption("--proxy-auth=".$proxyUser.":".$proxyPassword."");
    $client->getEngine()->setPath('/home/admin/web/xyz/public_html/bin/phantomjs');
    //$client->getEngine()->addOption("--proxy=".$proxy."");
    //$client->getEngine()->addOption("--proxy-auth=".$proxyUser.":".$proxyPassword."");
    $client->getEngine()->addOption("--proxy-type=http");

    $file = '/home/admin/web/xyz/public_html/stemp/pcookies.txt';
    $client->getEngine()->addOption('--cookies-file='.$file);

    $request  = $client->getMessageFactory()->createRequest();
    $response = $client->getMessageFactory()->createResponse();

    //$request->setMethod('GET');
    $data = array(
        'ctl00$ScriptManager1' => 'ctl00$MainContent$UpdatePanel2|ctl00$MainContent$pagerTop$ctl01$ctl02',
        //'ctl00$HiddenSearchCategory' => '#all',
        //'ctl00$searchtext' => '',
        //'ctl00$MainContent$HiddenFilter' => '[{"filterValue":"sprchove-zasteny","filterType":"pcategoria"},{"filterValue":"ctvrtkruhove-zasteny","filterType":"categoria"}]',
        //'ctl00$MainContent$ex2' => '7990,686990',
        //'min' => '7990',
        //'max' => '686990',
        'ctl00$MainContent$HiddenField1' => 'PageChanged',
        '__EVENTTARGET' => 'ctl00$MainContent$pagerTop$ctl01$ctl02',
        '__VIEWSTATE' => '',
        '__VIEWSTATEGENERATOR' => '5956E682',
        '__VIEWSTATEENCRYPTED' => '5956E682',
        '__ASYNCPOST' => 'true',
    );
    $request->setMethod('POST');
    $request->setUrl($url);
    $request->setRequestData($data);

    $client->send($request, $response);

    if($response->getStatus() === 200) {
        $content = $response->getContent();
    }

    return $content;
}

0 个答案:

没有答案