I'm trying to make an app that fetches some text from a website. But I got an error:
Error Domain=NSCocoaErrorDomain Code=256 "The file “XXX.aspx” couldn’t be opened." UserInfo={NSURL=...}
I can open the website using my browser. I think the problem is about the aspx file. So how do I get the html from a aspx file? Here is the code I used:
Here is the code I used:
let myURLString = "https://https://nutrition.sa.ucsc.edu/shortmenu.aspx?sName=UC+Santa+Cruz+Dining&locationNum=25&locationName=Porter+Kresge+Dining+Hall&naFlag=1&WeeksMenus=UCSC+-+This+Week%27s+Menus&myaction=read&dtdate=9%2f2%2f2019"
guard let myURL = URL(string: myURLString) else {
print("Invalid URL")
return
}
do {
let myHTMLString = try String(contentsOf: myURL, encoding: .ascii)
print("HTML : \(myHTMLString)")
} catch let error {
print("Error: \(error)")
}
Server Error in '/' Applicationerror with your link? Can you check it on browser?