I am trying to access https://www.blocket.se/store/login/0 using cURL to scrape some data, to turn them into tables to be used in a business intelligence program.
However when I try to access the website it says I have the wrong password/username.
"Du har angivit ett felaktigt användarnamn eller lösenord" >> "you have entered an incorrect username or password"
Edit: the data that I call the login function with uses the site I shared earlier in the post as the url and the second argument is retrieved via HTTPfox. They're just secret here.
Heres the code that I use to access the website:
function login($url,$data){
$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_TIMEOUT, 40000);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($login, CURLOPT_URL, $url);
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, $data);
ob_start();
return curl_exec ($login);
ob_end_clean();
curl_close ($login);
unset($login);
}
echo login("website", "email=secret@this.se&passwd=secret&store_id=secret");
Any help would be appreciated!