0

I created a simple http request in the following way:

source: Getting HTML Source from a URL without a Web Browser

var urlStr = "https://stackoverflow.com/";
var htmlStr = getHTMLSource(urlStr);
htmlStr.substring(0,200);

function getHTMLSource(pURL) {
  var nsURL     = $.NSURL.URLWithString(pURL);
  var nsHTML    = $.NSData.dataWithContentsOfURL(nsURL);
  var nsHTMLStr = $.NSString.alloc.initWithDataEncoding(nsHTML, $.NSUTF8StringEncoding);

  var htmlStr   = ObjC.unwrap(nsHTMLStr);

  return htmlStr;
}

However, how do I create a POST request and set the request header

kkxujq
  • 1
  • 1
  • You will need to use Objective-C's [`NSURLSession`](https://developer.apple.com/documentation/foundation/nsurlsession) class methods for this. Have a peruse of that linked documentation and see what you make of it. If you have specific questions, reply to this comment, tagging me in it. When I get my computer back in a few days, I'll draft a rough outline script that will show you how to implement it. – CJK Oct 20 '19 at 03:01
  • You didn't respond so I'll hold off writing a script until I hear from you that you're still interested, as it'll take me a bit of time that I don't mind putting towards something that is helpful to someone. – CJK Oct 26 '19 at 21:58

0 Answers0