Hot answers tagged

50

All we need to create an interactive Google Map in the notebook is access to the individual tiles - and there is a relatively simple naming scheme for those tiles. The most basic form of a tile URL looks like: http://mt0.google.com/vt/x=xi&y=yi&z=i, where $0\leq xi,yi < 2^i$. For example, at zoom level z=0, there is one tile representing the ...


34

As much as I would like to see a solution to this problem written in Mathematica, this is very unlikely given the scope of the problem. I would like to share a way to solve this using JLink, in the hope that it may help someone. JLink, for those who don't know, is a package that comes with Mathematica. It allows you to execute Java code from within ...


31

I recommend that you import as an XMLObject, which represents structured XML data in a Mathematica-based format. info = Import[ "http://area51.stackexchange.com/proposals/4470/martial-arts", "XMLObject"]; You can access the parts of xml using Mathematica patterns, like so: labels = Cases[info, XMLElement[ "div", {"class" -> "site-health-...


22

Animations as interactive visualizations The simplest form of interactive graphics is an animation in which the play head can be moved by the user. That doesn't sound very interactive, but in terms of functionality the play head is nothing but a type of Slider. With this simple interpretation of interactivity, any movie format supported by Export would be ...


17

You can always do Import["http://wsj.com","XMLObject"]. That has the side effect of producing some irregular XML whenever the underlying HTML doesn't quite map cleanly to XML, but it mostly produces an XMLObject[] expression tree that you can match over and extract data from, and I've never seen a web page for which it won't return something.


17

It seems networkx uses the D3 library and the example is based on this. We can adapt that code to work with Mathematica and generate JSON output from Mathematica. Save the HTML from the linked page to index.html. Change miserables.json in the source code to graph.json. Generate JSON with Mathematica: g = RandomGraph[BarabasiAlbertGraphDistribution[100, 1]...


16

Comment This was originally answered on Oct 2, 2012 using V8. The performance can be dramatically improved using V9's URLFetchAsynchronous, as now shown below. Fortunately, we needn't download all the tiles at once. We can use Dynamic to set up a little pan-and-zoom explorer. The first load takes a bit and zooming out takes a bit. Panning and zooming ...


16

Alright, follows are the regular expressions required to solve this. For further information on how these things work I would check out the regular expression documentation on the wolfram docs site. As far as how regular expressions themselves work, check out the perl regular expression man page. This is where I learned how to write regexes back when I was ...


16

I agree wholeheartedly with the comment of celtschk to the OP. Both journals have RSS feeds (with pointers at the bottom of their main pages) that are designed exactly for the purpose that you describe. I doubt that either journal wants you to "scrape" their content; scraping is specifically forbidden by the WSJ Terms of Use. I don't know how much easier ...


14

After much fiddling... This function gathers the "vital signs" of every proposal, and returns everything in a list. proposalURL = "http://area51.stackexchange.com/?tab=beta&page="; getProposalData[main_] := Module[{b, srclist, pnumber, imp1, url, imp2, proplist, proplinks, fullproplinks, propxml, health, propname, fulldata}, srclist = {}; ...


12

You do not really need a tool to depoly your CDF to HTML. It is very simple to do by hand. Here is what I do open your text editor and create a file called index.htm <HTML> <BODY > This is my CDF <p> <script src="http://www.wolfram.com/cdf-player/plugin/v1.0/cdfplugin.js" type="text/javascript"></script><script type="...


12

ClearAll[YandexTranslate]; YandexTranslate[string_String, lang_String, apikey_String: apikey] := StringCases[ URLFetch[ "https://translate.yandex.net/api/v1.5/tr.json/translate?key=" <> apikey <> "&text=" <> string <> "&lang=" <> lang <> "&format=plain" ], "[\"" ~~ x___ ~~ "\"]}" :>...


12

Since the Google Translate API requires authentication, a simple work around is to deploy as a web app a Google Apps Script that uses Google's LanguageApp, and then call that using URLExecute[]. To setup the Apps Script, go to script.google.com and create a new script with the following doGet function that uses the LanguageApp.translate method: function ...


12

Update 10-2017: I noticed that they released an update of these tools, so some of these steps are outdated. I adjusted this answer to the newest release of Workbench 10.1.822. It has become somewhat easier, therefore I also created an automated script for my usecase. Feel free to use it: (* Directory containing html folder, e.g. C:/project/build/...


10

The deploy functionality was introduced in Mathematica 8.0.4. To my knowledge, it is not available in 8.0.1.0, see the changelog.


10

I've got my own package that I've used for a few years to generate LaTeX from Mathematica. All the labs on my Mathematica course page were produced with this package. Here's a handout on probability theory for Calc II students that was produced by the package. Unfortunately, it's not at all polished and really not usable by anyone but me. I can present ...


10

To import as XMLObject is probably the cleanest approach, but since you asked for pattern matching I'll also post my answer which is similar to @nixeagle's but extracts instead the values together with their labels: src=Import["http://area51.stackexchange.com/proposals/4470/martial-arts","Source"]; StringCases[src, RegularExpression[ "<div\\s*class=\...


10

The different HTML entities are stored in System`Convert`MLStringDataDump`$HTMLEntities on version 9 and from here, it's a simple StringReplace: StringReplace["<select></select>", System`Convert`MLStringDataDump`$HTMLEntities] (* "&lt;select&gt;&lt;/select&gt;" *)


10

This will download the titles of all articles that transclude the Persondata template, if that's what you're trying to do. Flatten@NestWhileList[ Import["http://en.wikipedia.org/w/api.php?action=query&list=\ embeddedin&eititle=Template:Persondata&format=json&eilimit=500" <> If[Length@# > 1, "&eicontinue=" <> #[[2,...


10

This is an issue with XOWA. The HTTP Server was rewritten in v2.7.2 to handle POSTs and other features. However, it looks like it crashes on your request. I'll look at fixing this for v2.8.2. I'll comment again here when I have a resolution, but feel free to contact me directly for more info. Hope this helps! [Edit: This was fixed for v2.8.2. XOWA now ...


10

If you write an HTML img tag like this: <img src="url/to/image.jpg"> then the image will be downloaded directly upon page load. Some frontend developers don't like this as they think it's more important to quickly show the bulk of the page. The images can come later. So what they did in this case was writing <img data-src="url/to/image.jpg"> ...


9

Partial Solution Wolfram Workbench 2 and 3 are not able to launch the front end (Mathematica 10+) to create the final HTML. The solution is to use the new (Eclipse-plugin) version, downloadable from: https://www.wolfram.com/workbench/. Which is also free when you have purchased a Mathematica license. Some issues with the HTML edit: I took the time to ...


8

The short answer is no, there is no straightforward (built-in) way to convert Mathematica's dynamic objects to non-proprietary HTML+SVG/JS. To see why, consider how you might try ti represent the following very simple example in HMTL/SVG? Manipulate[With[{pts = {#, Sin[a*#]} & /@ (x /. Quiet[Solve[Sin[a*x] == b*AiryAi[-x] && 0 < x < 10, ...


8

Something like: ExportString[Cell[TextData["<select></select>"],"Text"],"HTML","FullDocument" -> False] produces: <p class="Text"> &lt;select&gt;&lt;/select&gt; </p> which might also be a good start.


7

No one tried to solve this importing as plain text. So this is my answer using using only string patterns: src = Import["http://area51.stackexchange.com/proposals/4470/martial-arts", "Plaintext"]; With[{cmt = Whitespace~~comment:("Excellent"|"Needs Work"|"Okay")}, StringCases[ src, { grade:NumberString~~...


7

Your code works fine—the site is just very stringent on the data supplied. I used Chrome's Inspect Element to see the values of all the input elements (including the hidden fields, as you'd noticed)—and I found that sometimes codigoColegio was left blank: It didn't work when I filled out codigoColegio to match nivel as you seemed to have done, but it did ...


7

Store data in question Tables could be left in plain text, with some encoding to remove CR and LF characters and other symbols. EncodeForQuestion[expr_List] := CopyToClipboard[ StringJoin["<data payload=\"", URLEncode[ExportString[expr, "CSV"]], "\"/>"]] Arbitrary data can be expressed as plain text with InputForm and ToString or compressed ...


6

For the benefit of those who come across this old question, I have recently written a small open-source library called MathCell that replicates the behavior of Mathematica's Manipulate using pure JavaScript. Documentation is available here. The library is not for converting Mathematica code, but is meant as a replacement for people who want to embed ...


6

Using JLink and Apache Commons Email and Java Mail it is not that hard to get MIME controlling working. I just modified some code I wrote some time ago (mostly for being able to send Email from within webMathematica) and added the ability to send HTML emails. It is a whole package with the jar files in subfolder and a Notebook with an example, so I hope it ...


6

I haven't seen a clear cut solution listed anywhere even though this question is quite old. Thus, I will post my solution here. The easiest solution is to use SVG format rather than to fiddle with JPEG, GIF, or PNG format. filePath = "path of the file"; nb = Import[filepath]; Export["my3.html", nb, "HTML", "GraphicsOutput" -> "SVG", "MathOutput" -> "...


Only top voted, non community-wiki answers of a minimum length are eligible