PHP POST değişkenler ile ASP.Net web kazıma

0 Cevap php

Son birkaç gündür ben bir web sitesi kazımak için çalışıyor ancak bugüne kadar hiçbir şans olmuştur.

The situation is as following: The website I am trying to scrape requires data from a form submitted previously. I have recognized the variables that are required by the web app and have investigated what HTTP headers are sent by the original web app.

Ben ASP.net hemen hemen sıfır bilgiye sahip beri, ben sadece burada bir şey eksik olup olmadığını sormak düşündüm.

I have tried different methods (CURL, get contents and the Snoopy class), here's my code of the curl method:

<?php
$url = 'http://www.urltowebsite.com/Default.aspx';
$fields = array('__VIEWSTATE' => 'averylongvar',
                '__EVENTVALIDATION' => 'anotherverylongvar',
                'A few' => 'other variables');

$fields_string = http_build_query($fields);

$curl = curl_init($url);

curl_setopt_array
(
    $curl,
    array
    (
        CURLOPT_RETURNTRANSFER  =>    true,
        CURLOPT_SSL_VERIFYPEER  =>    0,  //    Not supported in PHP
        CURLOPT_SSL_VERIFYHOST  =>    0,  //        at this time.
        CURLOPT_HTTPHEADER      =>
            array
            (
                'Content-type: application/x-www-form-urlencoded; charset=utf-8',
                'Set-Cookie: ASP.NET_SessionId='.uniqid().'; path: /; HttpOnly'
            ),
        CURLOPT_POST            =>    true,
        CURLOPT_POSTFIELDS      =>    $fields_string,
        CURLOPT_FOLLOWLOCATION => 1
    )
);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
?>

The following headers were requested:

Talep Başlıkları

  • Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5
  • Content-Type: application / x-www-form-urlencoded
  • User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5

Form Data

  • Form alanları bir sürü

Yanıt Başlıkları

  • Cache-Control: Özel
  • Content-Length: 30168
  • Content-Type: text / html; charset = utf-8
  • Tarih: Thu, 9 Eylül 2010 17:22:29 GMT
  • Sunucu: Microsoft-ııS/6.0
  • X-Aspnet-Version: 2.0.50727
  • X-Powered-By: ASP.NET

Ben yazdım CURL script başlıklarını araştırmak zaman nasılsa Form verileri isteği oluşturmaz. Ne POST ayarlanmış istek yöntemidir. Bu terslik nerede bana görünüyor, ama bilmem yerdir.

Herhangi bir Yardım takdir!

EDIT: Ben kazıma sonucu uzak bir web sitesine bir özel oturum süresi dolmuş sayfa olduğunu söylemeyi unutmuşum.

0 Cevap