如何通过wget或curl访问https页面?

时间:2015-05-25 03:56:20

标签: unix ssl curl wget

我想说我想要保存我的Facebook页面的内容。显然fb使用https,因此ssl,如何使用wget下载安全页面的内容?

我在网上发现了很多来源......我修改了我的命令,但它并没有保存我想要的页面。

wget --secure-protocol=auto "https://www.facebook.com/USERNAMEHERE" -O index.html

实际上这是我在index.html中得到的结果: "更新浏览器 您使用的是Facebook不支持的网络浏览器。 要获得更好的体验,请访问其中一个网站并获取您首选浏览器的最新版本:"

1 个答案:

答案 0 :(得分:6)

问题不在于SSL / https。问题是facebook看到" wget"作为代理并告诉"更新您的浏览器"。

你必须使用--user-agent开关欺骗facebook并模仿现代浏览器。

@IBOutlet weak var userEmailTextField: UITextField!
@IBOutlet weak var userPasswordTextField: UITextField!
@IBOutlet weak var repeatPasswordTextField: UITextField!

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func registerButtonTapped(sender: AnyObject) {

    let userEmail = userEmailTextField.text;
    let userPassword = userPasswordTextField.text;
    let userRepeatPassword = repeatPasswordTextField.text;

    // Check for empty fields
    if (userEmail.isEmpty || userPassword.isEmpty || userRepeatPassword.isEmpty)
    {

        // Display alert message

        displayMyAlertMessage("All fields are required");

        return;

    }
    // Check if passwords match
    if(userPassword != userRepeatPassword)
    {
      //Display an alert message
        displayMyAlertMessage("Passwords do not match");

        return;
    }

    // Store data
    NSUserDefaults.standardUserDefaults().setObject(userEmail, forKey: "userEmail");
    NSUserDefaults.standardUserDefaults().setObject(userPassword, forKey: "userPassword");
    NSUserDefaults.standardUserDefaults().synchronize();


    // Display alert message with confirmation.
    var myAlert = UIAlertController(title: "Alert", message: "Registration successful, Thank you!", preferredStyle: UIAlertControllerStyle.Alert);

    let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default){action in
        self.dismissViewControllerAnimated(true, completion: nil);
    }

    myAlert.addAction(okAction);
    self.presentViewController(myAlert, animated:true, completion:nil);

}

func displayMyAlertMessage(userMessage:String)
{

    var myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.Alert);

    let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil);

    myAlert.addAction(okAction);

    self.presentViewController(myAlert , animated: true, completion: nil)

}

然后,如果您在现代浏览器中打开index.html,您将看到实际的Facebook页面。