Message Boards Message Boards

0
|
791 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

CloudDeploy function returning error

Posted 1 year ago

Hi,

I've created a very simple API that imports the "Plaintext" of a URL or a PDF. Here is my code:

urlScraperTest = APIFunction[
   {"url" -> "String"},
   Import[#url, "Plaintext"] &];

And deployed it to the Wolfram Cloud:

CloudDeploy[urlScraperTest, "urlScraper", Permissions -> "Public", CloudObjectNameFormat -> "CloudUserUUID"]

CloudObject["https://www.wolframcloud.com/obj/user-7d8eeec4-69a3-4149-bc75-10de306a3cbd/urlScraper"]

I want to be able to call this API from programs outside of MMA. In testing the code, things seem to work as expected for some URLs. For instance, here is a link to a recipe that I am able to call directly from my browser

This code works fine if I pass it some URLs, e.g. here is a recipe that I am able to scrape from my browser:

https://www.wolframcloud.com/obj/user-7d8eeec4-69a3-4149-bc75-10de306a3cbd/urlScraper?url=https://www.foodandwine.com/recipes/beef-wellington

I'm also testing this by passing the URL of a PDF that I've stored in a cloud location: https://bbf184a8c110ea5f6bb4192bc1d23ad5.cdn.bubble.io/f1703793538605x556426251682794500/Perfect%20Chocolate%20Chip%20Cookies%20Recipe%20-%20NYT%20Cooking.pdf

If I enter this location in my browser search bar directly, the PDF renders correctly. But if I try to pass this URL to my Wolfram Cloud api function

https://www.wolframcloud.com/obj/user-7d8eeec4-69a3-4149-bc75-10de306a3cbd/urlScraper?url=https://bbf184a8c110ea5f6bb4192bc1d23ad5.cdn.bubble.io/f1703793538605x556426251682794500/Perfect%20Chocolate%20Chip%20Cookies%20Recipe%20-%20NYT%20Cooking.pdf

If produces a $Failed message. Note: If I call the URLScraperTest[] function directly from a local MMA notebook using the above URL, it does return the results I expect with no error. But I need to be able to call this function from outside of MMA.

I believe the problem is that the URL above contains "illegal" characters for URL encoding, but I've been unable to find a solution. Can anyone suggest a solution?

Thanks!
Mark

POSTED BY: Mark Coleman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract