I want to scrape some information from a pokerplatforms webpage.
For that I need to login (post) on the https webpage “www.name.com”. But the information is placed on a subdomain “poker.name.com”. The login works pretty well but when i GET the site from the subdomain libcurl sets up a new connection obv with new cookies. Then I get a page reminding me that i have to log in.
Now my question is how i can force libcurl to use the same connection or at least the same cookie to GET the page from the subdomain.
EDIT:
Not the solution to my quetsion but works fine: I just logged in to the subdomain. The login skript exists there too.
When you enable cookies for a libcurl handle, you can then just re-use that handle on subsequent requests and libcurl will use cookies automatically.
If you insist on closing the handles and creating new ones, then CURLOPT_COOKIEJAR is the option you want to save the cookies into a file and CURLOPT_COOKIEFILE can then subsequently read them back again from such a file. Alternatively, you can use libcurl’s share interface to have multiple handles share cookies.
Then, in order to “properly” mimic a browser on a site like this, you really should record the HTTP headers sent and received during a manual session so that you can be sure your program uses the same URLs and data as your browser did.