A
A
Andrew2015-01-28 04:01:55
PHP
Andrew, 2015-01-28 04:01:55

How to parse different pages on a site with authorization?

Hello.
There is a need to parse some data in your account of one service. I use cURL for authorization, it turned out well to authorize, but there was a difficulty at the stage when you need to go through several categories, each category has a pager, where there can be a dozen more pages. It turns out that I can’t use file_get_contents(), and for each next page, opening a new curl session is too bold in my opinion, including the code ... How to accurately solve my problem? How do people generally act in such a case? Maybe I missed some point? Can you show an example how to do this?
UPD:
I was hoping, just that there is some way to log in, close the cURL session and then process data, take other pages, and so on outside the session ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2015-01-28
@ntzch

why file_get_contents when you use curl? without closing the session just open another page

$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, 'fantasyland.ru/login.php');
curl_setopt($handle, CURLOPT_POST, 1);
curl_setopt($handle, CURLOPT_POSTFIELDS, 'login=ххх&password=ххх');
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($handle, CURLOPT_HEADER, 0);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($handle, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_exec($handle);

curl_setopt($handle, CURLOPT_URL, 'fantasyland.ru/cgi/v_trade_load_all.php');
$page = curl_exec($handle);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question