Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

bir curl masalı


curlzede

Öne çıkan mesajlar

ing için kusura bakmayın.

hi,

i am trying to login an ashx page with curl. Following data from livehttpheaders:

http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx

POST /ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx HTTP/1.1
Host: www.milliyetemlak.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: tr-tr,tr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
X-AjaxPro-Method: Login
Referer: http://www.milliyetemlak.com/Default.aspx?aType=UyeGiris
Content-Length: 204
Cookie: IlanOnPlan=FlashIlan=9; KategoriyeGoreIlanlar=12,13,=12; FirmaOnplan=FirmaVitriniEmlakci=0&FirmaVitrinInsaat=0&FirmaVitrinYapiDekorasyon=0&NakliyeciVitrini=0; __utma=183063866.786731720.1278014512.1278164210.1278174821.6; __utmz=183063866.1278014512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FirmaOnplan1=FirmaVitriniEmlakci1=0&FirmaVitrinInsaat1=0&FirmaVitrinYapiDekorasyon1=0&NakliyeciVitrini1=0; ASP.NET_SessionId=kt33i5yukc1pvu55gf5jnojl; NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660; __utmc=183063866; bttest__=123; LoginInfo=email=&password=; __utmb=183063866.3.10.1278174821
Pragma: no-cache
Cache-Control: no-cache
{"username":"[email protected]","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 41
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: LoginInfo=email=17CC6ABA347F6FC659FD9DF4BE522553A0C2C1FEAF4021F5DF611A33FB6DAD440F34DD64B16A84DBD2F6AC246FC474DC3DF2B616F6A7BD4CFF429F47ABF7607C69D2E92A577D709D666A115F9739E0EB31D05A7DFFF9ECBCD21202ED28BFB153B0831864878BC8D447F7F390F1653BA9&password=337AAE4F702987DC86AF42DB5E26974E166B019F19819207A07029BF3C3DA46CBF3654DA4C03F4ECC41A26150810A6CF18DAB880624EC8930005F3FC7B56B433313728E095025F6B573396D8D03C72E6; expires=Fri, 01-Oct-2010 16:35:18 GMT; path=/
Set-Cookie: NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660;expires=Sat, 03-Jul-2010 20:28:20 GMT;path=/;httponly
Date: Sat, 03 Jul 2010 16:35:17 GMT


and this is my php code for it:


<?php

$loginurl = "http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx";

echo curl_login($loginurl,$data,'','off');
echo "<br><hr><br>";
// loginning
echo curl_grab_page('http://www.milliyetemlak.com/','','off');
echo "<br><hr><br>";

// ilan gönderiyoruz

function curl_login($url,$data,$proxy,$proxystatus){
$fp = fopen("cookie.txt", "w");
fclose($fp);
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($login, CURLOPT_TIMEOUT, 40);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
if ($proxystatus == 'on') {
curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($login, CURLOPT_PROXY, $proxy);
}
curl_setopt($login, CURLOPT_URL, $url);
curl_setopt($login, CURLOPT_HEADER, TRUE);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($login, CURLOPT_POST, TRUE);
curl_setopt($login, CURLOPT_POSTFIELDS, '{"username":"[email protected]","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}');
ob_start(); // prevent any output
return curl_exec ($login); // execute the curl command
ob_end_clean(); // stop preventing output
curl_close ($login);
unset($login);
}

function curl_grab_page($site,$proxy,$proxystatus){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
if ($proxystatus == 'on') {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
}
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_URL, $site);
ob_start(); // prevent any output
return curl_exec ($ch); // execute the curl command
ob_end_clean(); // stop preventing output
curl_close ($ch);
}

?>


and following code is here:

http://www.sozluklerinefendisi.com/mitest.php

it isn't working.

created cookie.txt is here:


# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.milliyetemlak.com FALSE / FALSE 1278188457 NSC_fnmblnjmmjzfu ffffffffd6fb026745525d5f4f58455e445a4a423660



any idea ?

thanks for looking anyway : )
Link to comment
Sosyal ağlarda paylaş

Default.aspx?aType=UyeGiris daki adresteki form Member.aspx?action=Login'e postluyor veriyi.

Tek curl içinden o adresi yazınca her hangi bir viewstate değeri dönmüyor.

Livehttpheaders'da ise ashx sayfasına postluyor. Formdaki verilerden hareketle username ve password dışında bir şey gitmemesi lazım.

Postveriyi

[email protected]&txtPassword=pass&__VIEWSTATE=$viewstate şeklinde regexp ile döndüremiyorum yani.

Uyegiris'deki çekilen viewstate i yerleştirince wEPDwUKMTQ3Mjg3NjY1M2Rk yine cookieleri düzgün almıyor.
Link to comment
Sosyal ağlarda paylaş

di said:

Once veriyi duzgun araklayamiyorum diye aglayip sonra da veriyi daha duzgun araklamak icin yol yordam soruyorsun.

Senin o verilerini almani isteseler zaten kendileri yol yordam soylerler.


Ya arkadaş sen niye böyle ukala bilmiş davranmak zorunda hissediyorsun kendini ?

Yapmaya çalıştığım şey veri araklamak filan değil, hali hazırda pek çok ilanı bir müşterinin isteği üzerine buraya aktaracak bir sistem düzenlemek.

Adam da parasını verip sisteme üye olmuş ama binlerce ilanı girmek yerine web sitemdeki ilanları buraya otomatik aktaracak bir şey lazım bana mümkün mü dedi.

Ben de teorik olarak evet bakalım dedim uğraşıyorum.

İlla arakçı/hırsız yakıştırması yapıp asab bozmak zorunda mısın ? Arakçı çok her halde sülalende.

Ruhsal sorunları olan insanlar lütfen şu konudan uzak dursun. Çok zor değil mesaj yazmayın olur biter.
Link to comment
Sosyal ağlarda paylaş

Adamın sülalesine kadar girmişsin ama, böyle hart diye veri almak suç kapsamına girebilir. Bazı bahis siteleri ile görüşmüştüm veri akışı sunuyo musunuz, sunmuyosanız parse ederek alabilir miyiz diye; aylık 2-3 bin liraya XML veya JSON olarak sunuyoruz, sitemizden parse ederseniz de yasal yollara başvururuz demişlerdi.
Link to comment
Sosyal ağlarda paylaş

ing için kusura bakmayın.

hi,

i am trying to login an ashx page with curl. Following data from livehttpheaders:

http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx

POST /ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx HTTP/1.1
Host: www.milliyetemlak.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: tr-tr,tr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
X-AjaxPro-Method: Login
Referer: [www.milliyetemlak.com]
Content-Length: 204
Cookie: IlanOnPlan=FlashIlan=9; KategoriyeGoreIlanlar=12,13,=12; FirmaOnplan=FirmaVitriniEmlakci=0&FirmaVitrinInsaat=0&FirmaVitrinYapiDekorasyon=0&NakliyeciVitrini=0; __utma=183063866.786731720.1278014512.1278164210.1278174821.6; __utmz=183063866.1278014512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FirmaOnplan1=FirmaVitriniEmlakci1=0&FirmaVitrinInsaat1=0&FirmaVitrinYapiDekorasyon1=0&NakliyeciVitrini1=0; ASP.NET_SessionId=kt33i5yukc1pvu55gf5jnojl; NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660; __utmc=183063866; bttest__=123; LoginInfo=email=&password=; __utmb=183063866.3.10.1278174821
Pragma: no-cache
Cache-Control: no-cache
{"username":"[email protected]","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 41
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: LoginInfo=email=17CC6ABA347F6FC659FD9DF4BE522553A0C2C1FEAF4021F5DF611A33FB6DAD440F34DD64B16A84DBD2F6AC246FC474DC3DF2B616F6A7BD4CFF429F47ABF7607C69D2E92A577D709D666A115F9739E0EB31D05A7DFFF9ECBCD21202ED28BFB153B0831864878BC8D447F7F390F1653BA9&password=337AAE4F702987DC86AF42DB5E26974E166B019F19819207A07029BF3C3DA46CBF3654DA4C03F4ECC41A26150810A6CF18DAB880624EC8930005F3FC7B56B433313728E095025F6B573396D8D03C72E6; expires=Fri, 01-Oct-2010 16:35:18 GMT; path=/
Set-Cookie: NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660;expires=Sat, 03-Jul-2010 20:28:20 GMT;path=/;httponly
Date: Sat, 03 Jul 2010 16:35:17 GMT


and this is my php code for it:


<?php

$loginurl = "[www.milliyetemlak.com];;

echo curl_login($loginurl,$data,'','off');
echo "<br><hr><br>";
// loginning
echo curl_grab_page('http://www.milliyetemlak.com/','','off');
echo "<br><hr><br>";

// ilan gönderiyoruz

function curl_login($url,$data,$proxy,$proxystatus){
$fp = fopen("cookie.txt", "w"winking smiley;
fclose($fp);
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"winking smiley;
curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"winking smiley;
curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"winking smiley;
curl_setopt($login, CURLOPT_TIMEOUT, 40);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
if ($proxystatus == 'on') {
curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($login, CURLOPT_PROXY, $proxy);
}
curl_setopt($login, CURLOPT_URL, $url);
curl_setopt($login, CURLOPT_HEADER, TRUE);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($login, CURLOPT_POST, TRUE);
curl_setopt($login, CURLOPT_POSTFIELDS, '{"username":"[email protected]","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}');
ob_start(); // prevent any output
return curl_exec ($login); // execute the curl command
ob_end_clean(); // stop preventing output
curl_close ($login);
unset($login);
}

function curl_grab_page($site,$proxy,$proxystatus){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
if ($proxystatus == 'on') {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
}
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"winking smiley;
curl_setopt($ch, CURLOPT_URL, $site);
ob_start(); // prevent any output
return curl_exec ($ch); // execute the curl command
ob_end_clean(); // stop preventing output
curl_close ($ch);
}

?>


and following code is here:

[www.sozluklerinefendisi.com]

it isn't working.

created cookie.txt is here:


# Netscape HTTP Cookie File
# [www.netscape.com]
# This file was generated by libcurl! Edit at your own risk.

www.milliyetemlak.com FALSE / FALSE 1278188457 NSC_fnmblnjmmjzfu ffffffffd6fb026745525d5f4f58455e445a4a423660



any idea ?

thanks for looking anyway : )
Link to comment
Sosyal ağlarda paylaş

her ne kadar sitedeki hazımsız insanların yarattığı kirliliğe rağmen çözümü birilerinin işine yarayabileceği gerekçesi ile paylaşıyorum.

kodlara httpheaders bilgisi eklemek gerekiyormuş. yani:

headers

$header_array[0] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; $header_array[1] = 'Accept-Language: pl,en-us;q=0.7,en;q=0.3'; $header_array[2] = 'Accept-Encoding: gzip,deflate'; $header_array[3] = 'Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7'; $header_array[4] = 'Keep-Alive: 115'; $header_array[5] = 'Connection: keep-alive'; $header_array[6] = 'Content-Type: text/plain; charset=utf-8'; $header_array[7] = 'X-AjaxPro-Method: Login';

curl_setopt($login, CURLOPT_HTTPHEADER, $header_array);

Link to comment
Sosyal ağlarda paylaş

×
×
  • Yeni Oluştur...