我正在尝试使用cURL访问https://www.blocket.se/store/login/0来抓取一些数据,将它们转换为用于商业智能程序的表格。
但是,当我尝试访问该网站时,它说我的密码/用户名错误。
“Du har angivit ettfelaktigtanvändarnamnlerlerösenord”>> “您输入了错误的用户名或密码”
编辑:我称之为登录功能的数据使用我之前在帖子中共享的网站作为网址,第二个参数通过HTTPfox检索。他们在这里只是秘密。
以下是我用来访问网站的代码:
public class employee()
{
public int EmployeeNumber{get;set;}
public string EmployeeFirstName{get;set;}
public string EmployeeLastName{get;set;}
}
任何帮助将不胜感激!
答案 0 :(得分:0)
解决了它
function login($url, $data) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, "https://www.blocket.se/store/login/0");
return curl_exec($ch);}
添加引用并将标头设置为false解决了它。如果任何其他瑞典人需要访问,这至少适用于blocket!