Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> cURL wejscie na strone z uprzednio pobranym session_id
matird
post
Post #1





Grupa: Zarejestrowani
Postów: 30
Pomógł: 5
Dołączył: 12.09.2010
Skąd: Kraków / Wrocław

Ostrzeżenie: (0%)
-----


Witam, przeczytałem dziesiątki tematów i żaden ze sposobów nie działa... To co chce uzyskać - wejść na stronę aby zarejestrować sesję, następnie wejść na tę stronę jeszcze raz podając w adresie pobrany wcześniej session_id. Bez tego nie mogę wejść na stronę wyszukiwania. Błąd jaki pokazuje strona(!) : session expired... Więc chyba jest zamykana po pierwszej wizycie...

  1. <?php
  2.  
  3. $pageurl = "http://jobseekers.direct.gov.uk/homepage.aspx";
  4. $ch1 = curl_init($pageurl);
  5. curl_setopt($ch1, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');
  6. curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
  7. // gzip
  8. curl_setopt($ch1, CURLOPT_ENCODING, 'gzip');
  9. // deflate
  10. curl_setopt($ch1, CURLOPT_ENCODING, 'deflate');
  11. curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, 1);
  12. // gzip, deflate
  13. curl_setopt($ch1, CURLOPT_ENCODING, 'utf-8');
  14. curl_setopt($ch1, CURLOPT_HEADER, 1);
  15. curl_setopt($ch1, CURLOPT_NOBODY, 1);
  16. curl_setopt ($ch1, CURLOPT_URL, $pageurl );
  17. $html = curl_exec ( $ch1 );
  18. curl_close($ch1);
  19.  
  20. preg_match_all('#sessionid=(.*?)&pid#si',$html,$matches);
  21. $id = $matches[1][0];
  22.  
  23. $headers = array('Accept-Language: pl,en-us;q=0.7,en;q=0.3',
  24. 'Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7');
  25.  
  26. $ch = curl_init('http://jobseekers.direct.gov.uk/listjob.aspx?sessionid='.$id.'&pid=2&sid=322801553&p=1&so=1');
  27. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');
  28. // gzip
  29. curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  30. // deflate
  31. curl_setopt($ch, CURLOPT_ENCODING, 'deflate');
  32. // gzip, deflate
  33.  
  34. curl_setopt($ch, CURLOPT_ENCODING, '');
  35. curl_setopt($ch, CURLOPT_HEADER, 1);
  36. curl_setopt($ch, CURLOPT_NOBODY, 0);
  37. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  38. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  39. echo curl_exec($ch);
  40. curl_close($ch);
  41. ?>

coś tu nie gra, może macie jakieś pomysły ?

@edit: w ciastkach nie ma dosłownie nic, sprawdzałem. Po prostu jakoś zapomina o poprzedniej sesji

@edit:
headersy po pierwszym cURL i odpowiednio po drugim:
HTTP/1.1 302 Found Date: Sat, 29 Oct 2011 03:24:53 GMT Location: /homepage.aspx?sessionid=8c349585-d57d-4ea6-92ea-b757829d5a07&pid=1 Cache-Control: no-cache Pragma: no-cache Expires: -1 Content-Type: text/html; charset=utf-8 Content-Length: 194 HTTP/1.1 200 OK Date: Sat, 29 Oct 2011 03:24:53 GMT Cache-Control: no-cache Pragma: no-cache Expires: -1 Content-Type: text/html; charset=utf-8 Content-Length: 27467

HTTP/1.1 302 Found Date: Sat, 29 Oct 2011 03:24:53 GMT Location: /homepage.aspx?sessionid=8c349585-d57d-4ea6-92ea-b757829d5a07&pid=2 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 194 HTTP/1.1 302 Found Date: Sat, 29 Oct 2011 03:24:53 GMT Location: /homepage.aspx?sessionid=5357b28f-b515-44e3-a411-c7c8cce05494&pid=1 Cache-Control: no-cache Pragma: no-cache Expires: -1 Content-Type: text/html; charset=utf-8 Content-Length: 194 HTTP/1.1 200 OK Date: Sat, 29 Oct 2011 03:24:53 GMT Cache-Control: no-cache Pragma: no-cache Expires: -1 Content-Type: text/html; charset=utf-8 Content-Length: 27833

Ten post edytował matird 29.10.2011, 04:27:59
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 09:07