8
$\begingroup$

My question is about why Import executed in Wolfram Cloud with a fixed value (see A) works and with a variable (see B) doesn't when you use the form and submit the value 5565471199 (same as the fixed one in A).

A:

CloudDeploy[
 FormPage[{"searchURLp" -> "String"}, 
  Import[URLBuild[{"http://www.allabolag.se/", "5565471199"}], 
   "Data"]]]

B:

CloudDeploy[
 FormPage[
  {"searchURLp" -> "String"}, 
  Import[URLBuild[{"http://www.allabolag.se/", #searchURLp}], "Data"] &
  ]
 ]

"A" returns a list of publicly available company data from the site (see picture below. "B" fails.

Result from A

$\endgroup$
7
  • $\begingroup$ Might be a bug on the Import when executed in the Cloud, see community.wolfram.com/groups/-/m/t/… $\endgroup$ – FredrikD Oct 24 '15 at 13:10
  • $\begingroup$ I agree that that Wolfram Community answer seems highly relevant here, probably the same issue. $\endgroup$ – C. E. Oct 24 '15 at 17:43
  • $\begingroup$ @Pickett, should I tag it as a bug then? $\endgroup$ – FredrikD Oct 25 '15 at 12:09
  • $\begingroup$ Yes, I think that's appropriate, I added it now. However the tag is not that important, the important thing is that you report it to WRI so that they know that people are having this problem. You can use the "Give feedback" menu alternative under "Help" in Mathematica. $\endgroup$ – C. E. Oct 25 '15 at 15:15
  • 1
    $\begingroup$ That's a good idea I think. Of course it can still be about the bug, but you can open up for answers about workarounds as well. $\endgroup$ – C. E. Nov 19 '15 at 14:36
2
$\begingroup$

Import HTML data:

CloudDeploy[
   FormPage[{"searchURLp" -> "String"},
      Import[URLBuild[{"http://www.allabolag.se/", #searchURLp}], "Data"] &],
   FileNameJoin[{$CloudRootDirectory, "FormPageImport"}]]

Wolfram Development Platform FormPage:

FormPage input and output

Update Dec 13 '15

Wolfram developers have resolved the issue with cloud deploy of Import[url, "Data"].

Private verses public Wolfram Cloud

The Wolfram Development Platform offers two general approaches to parsing HTML (or for that matter solving just about any other cloud development problem). On the one hand, you could deploy your application to the public cloud and roll out new features as the Wolfram Language adds the required HTML parsing functions. On the other hand, you could deploy to a private cloud and link to any one of presumably numerous and excellent HTML parsing packages written in the language of your choice. If you start with the first approach, you will be able to quickly create an application that parses HTML on the public cloud. Meanwhile, start planning to set up your own private Wolfram Cloud and experimenting with external HTML parsing packages. (It could be that under the hood the Wolfram HTML parser is actually calling a popular HTML parsing library and your private cloud system could make calls to this same library.) As your cloud application grows, the up front cost of setting up a private Wolfram Cloud might be very much outweighed by the increased flexibility and power that a private cloud offers over the public one.

Comment

Example A imports HTML on the desktop, puts the resulting output in the FormPage second argument, and then deploys to the could. Only example B is actually attempting to import HTML in the cloud.

Import and the ImportString URLFetch combination produce identical results on the desktop:

Import[url,"Data"]===ImportString[URLFetch[url],"Data"]

The same is true in the cloud. With a bit more work it can also be shown that on the desktop and in the cloud Import gives the same result and that URLFetch returns essentially the same full page HTML string.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.