Cooler_

spider odin

Sep 4th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.49 KB | None | 0 0
  1.     curl = curl_easy_init();
  2. //GET
  3.     curl_easy_setopt(curl,  CURLOPT_URL, POST?arg[0]:make);
  4. //caso seja post inves de GET
  5.     if(POST)
  6.      curl_easy_setopt(curl, CURLOPT_POSTFIELDS, make);
  7. // response fica em um pedaço da memoria
  8.     curl_easy_setopt(curl,  CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
  9.     curl_easy_setopt(curl,  CURLOPT_WRITEDATA, (void *)&chunk);
  10. // caso usuario tenha definido um useragent
  11.     if(arg[6]!=NULL)
  12.      curl_easy_setopt(curl,  CURLOPT_USERAGENT, arg[6]);
  13. // do contrario vamos usar o useragent padrao
  14.     else
  15.      curl_easy_setopt(curl,  CURLOPT_USERAGENT, "Mozilla/5.0 (0d1n v0.1) ");
  16. // para comprimir
  17.     curl_easy_setopt(curl,  CURLOPT_ENCODING,"gzip,deflate");
  18. //uso futuro do timeout
  19. //    curl_easy_setopt(curl, CURLOPT_SETIMEOUT,3);
  20. //caso seja definido um cookiejar
  21.     if(arg[3]!=NULL)
  22.     {
  23.      curl_easy_setopt(curl,CURLOPT_COOKIEFILE,arg[3]);
  24.      curl_easy_setopt(curl,CURLOPT_COOKIEJAR,arg[3]);
  25.     } else
  26. // do contrario cria uma arquivo em branco para armazenar os cookies
  27.      curl_easy_setopt(curl,CURLOPT_COOKIEJAR,"odin_cookiejar.txt");
  28. // caso tenha redirecionamento
  29.     curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
  30. // nao verifica cert SSL
  31.     curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,0);
  32. // mostra header no response
  33.     curl_easy_setopt(curl,CURLOPT_HEADER,1);
  34.     curl_easy_perform(curl);
  35. // para pegar status,200,403...
  36.     curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,&status);
  37.     curl_easy_cleanup(curl);
Advertisement
Add Comment
Please, Sign In to add comment