Hot answers tagged

30

I have made some time ago a Mathematica code to play with my Facebook graph. The code extracts your Facebook friends, photos, relationships and constructs a PDF file that you can click in your friend's picture to open their Facebook and see they relations. The result is like this: And the zoom in PDF is great, see: The notebook is here. To use it, you ...


29

In a post about automated image uploading Arnoud Buzing describes an undocumented and unsupported POST method. It looks like this: xml = Import[url, "XML", "RequestMethod" -> "POST", "RequestParameters" -> {"key" -> key, "image" -> image}]; Note: at the time of this answer I was using V8. Since the arrival of URLFetch in V9 I ...


28

Using the (deprecated but easy) API documented here, result = Import[ "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey", "JSON"] Import["url" /. ("results" /. ("responseData" /. result))[[1]]] If you hit the service too many times, it'll lock you out for a while. Here's another example that gives the 24th-32nd ...


26

Certainly. There have indeed been some changes to certain tags in the 2.1 API and also to the method to sort out how many pages to import. And, since we are now a full site under StackExchange, the server has changed and a site parameter was necessary. I did a bit of clean-up, hardened the code a little to accommodate connection failures, made the basic ...


21

With this function a random integer is inserted in the e-mail address (gmailuser@gmail.com becomes gmailuser+randominteger@gmail.com) and then the hash value is computed. The hash value is used to get the corresponding identicon from the Gravatar website. This approach can address also some privacy concerns. generatePic[email_] := Module[{emailparts, ...


20

webShot[URI_String] := Import["http://www.sciweavers.org/iWeb2Shot?url=" <> URI] webShot["google.com"] Another one: webShot["http://mathematica.stackexchange.com/questions/20486/import-the-thumbnail-of-an-internet"]


18

Use URLFetch in Mathematica 9.0.1.


18

MoMA res= {1,2,3..} is the resolution.Use res = -1 for the max available resolution, but beware of a shipload of lawyers, middle managers, telephone sanitisers and hairdressers that may try to prosecute you if you use a value greater than 1, moma[catalogueNumber_, res_] := Module[{m = "http://www.moma.org", src, sj, rep, exp, a}, rep = {"]" -> "}", ...


17

I now have part of the picture. There is an undocumented function called HTTPClient`OAuthAuthentication[] which takes only options as arguments. These options settings override defaults that are visible in HTTPClient`OAuth.m. Here is an example of how to make get an OAuth 1.0a style access token, in this case for the Withings API: token = HTTPClient`...


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 ...


15

There is a setting in Mathematica that controls whether it can access the internet. Go to Preferences -> Internet Connectivity and uncheck "Allow the Wolfram System to access the Internet". Disabling this will disable some features that depend on internet access, such as Wolfram|Alpha queries. This setting can also be controlled by the $AllowInternet ...


14

Using the great example of Szabolcs from here, I implemented the following little function that solves my problem. You must give it a List of Rules, and it will send them to the hard-coded web-service endpoint inside. To test it, I implemented a little NodeJs server that reads the JSON body of a POST request, parses it, unparses it, and sends it back. So ...


14

Seeing as how someone has been nice enough to write the C-code for you, you could just use that. Assuming you have a C compiler on your machine, here's how you use it within Mathematica. Note that code is defined below. (* Be sure to define code first! *) Needs["CCompilerDriver`"]; url = "http://www.stackexchange.com/"; checksum = CreateExecutable[code, "...


13

Van Gogh Museum Here is the same for the tiles structure of the Van Gogh Museum at @bills' request. Note that the structure is completely different. I preserved the same resolution convention: vanInTheSkyWithLucy[catalog_, res_] := Module[{i, df, zooms, c, maxXY, t}, i = Import["http://www.vangoghmuseum.nl/en/collection/" <> catalog, "XMLObject"]...


12

I am not sure what exactly that rank mean. But here's direct rough porting of code: ConvertStrToInt[url_String, init_, factor_] := Fold[FromDigits[IntegerDigits[#1*factor + #2, 16, 8], 16] &, init, ToCharacterCode[url]]; HashURL[url_String]:= Block[{c1, c2,t1, t2}, c1=ConvertStrToInt[url, 5381,33]; c2=ConvertStrToInt[url, 0,65599]; ...


11

I found some free gis data of indian roads. I extracted the india-latest.shp.zip and then imported the roads.shp file. Here is a quick example to extract relevant roads: (* Make sure to fix the path *) indiaRoadData = Import["india-latest.shp/roads.shp", "Data"]; (* This just happens to be where the Lines are located in the data, see below for some ...


10

Two solutions: Use the listability of Interpreter to parallelize calls to WR servers: In[1]:= AbsoluteTiming[Interpreter["Time"][timeData]] // First Out[1]= 6.551647 Use Structured interpreters to avoid calling WR servers altogether: In[2]:= AbsoluteTiming[Interpreter["StructuredTime"][timeData]] // First Out[2]= 0.165715 In general you might ...


9

I implemented this function using YQL: acquireOptions[stock_String, expiration_, type_] := Module[{options, list, data}, options = Cases[Import[ "http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20yahoo.finance.option_chain%20WHERE%20symbol%3D'" <> stock <> "'%20AND%20expiration%3D'" <> expiration <> "'%20and%...


9

Yep, as @Sjoerd mentions in the comments, 10.1 includes the WikipediaData functionality. You can use like this: links = WikipediaData["Mathematica", "BacklinksRules", "MaxLevelItems" -> 10, "MaxLevel" -> 2] Graph[links, VertexLabels -> Placed["Name", Tooltip], VertexStyle -> {"Mathematica" -> Red}]


8

Mathematica now supports a native connection to GoogleCustomSearch API. To use image search you can do: gs = ServiceConnect["GoogleCustomSearch"] gs["Search",{"Query"-> "Jennifer Lawrence","SearchType"-> "Image"}] To use GoogleCustomSearch API you need an API Key and a Custom search engine ID. To get the API Key you first have to go to https://...


8

Thanks to @halirutan and @Szabolcs, I found a working solution by myself. Apparently it won't work with localhost on Windows7 but with 127.0.0.1. To sum up, I present the ssh-commands, so other users might gain something from this (use your own network names or IPs here): First connect through the firewall via ssh.server: ssh -L 16286:127.0.0.1:16286 ...


7

It might make sense to try to import the data from WolframAlpha, seeing as how they've gone to the trouble to set it up. Unfortunately, the support for doing so is a bit disappointing, as it can't be accessed directly through Mathematica. I imagine that a future version will support this but, for the time being, this is available only via WolframAlpha Pro'...


7

If you are regularly sending email back and forth to a small number of people, then SendMail with the Google “less secure apps” setting is a very good solution. On the other hand, if you send or aspire to send, a large number of transactional or marketing emails every day, then an email delivery service may give a much better delivery success rate. For ...


7

Some services provided by Mathematica require Mathematica to access our servers through the internet. The privacy policy on this topic can be found here: http://www.wolfram.com/legal/privacy/wolfram-mathematica.html


6

I wrote this in the comment, but the code did not come out properly formatted. So here it is again: Import["https://en.wikipedia.org/wiki/Mathematica", "Images"]


5

If you're downloading a website it may not be entirely static. So you need to download the file and check the headers at the same time, you cannot do it separately. Therefore URLSave is easier to use, even though URLFetch can also to be used. Like Joel Klein says there isn't a checksum by default for every page. However, we could use the header Content-...


5

There's no easy way, it's a custom script that assembles the image out of individual slices, and it's written by someone who clearly didn't intend anyone to read it again (including himself). Reverse engineering. The script responsible is http://imgs.xkcd.com/clickdrag/1110.js, the image to be displayed is assembled in line 86 ($image=...). Scanning the ...


5

You can download all the original tiles using the following functions. 404 and file not founds are handled gracefully. I'm avoiding displaying to the FE so as to lower the chances of crashing. url[n1_Integer, d1_String, n2_Integer, d2_String] := "http://imgs.xkcd.com/clickdrag/" <> ToString@n1 <> d1 <> ToString@n2 <> d2 <> ...


4

You question does basically not fit here, but I'm sure it is still one of the best places to ask. I think we shouldn't be too pedantic with the rules. Let me give you some advice, which will unfortunately only help you, if you can cooperate with your admin of the server: You have to ensure, that you can reach the license server over an IP, because this is ...


4

using Mathematica 9 the easiest way is URLSave URLSave["http://www.nytimes.com" , "C:\\temp\\test9.html"] you get the output "C:\temp\test9.html" and then directly from within Mathematica open your html default browser SystemOpen[%] with earlier versions try the following source = Import["http://www.nytimes.com", "Source"]; Export["C:\\temp\\test8....



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