Tag Info

Hot answers tagged

28

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


27

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

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


21

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


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"]


19

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


17

Use URLFetch in Mathematica 9.0.1.


17

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 = {"]" -> "}", ...


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

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


14

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


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


12

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


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}]


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


9

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


9

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


7

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


6

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

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


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

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


4

I suspect this is in the documentation, but just in case it is not obvious, one can indicate the import format as the first element of an array in the 2nd argument to Import: Import["http://www.soccerbase.com/teams/transfers.sd?season_id=142& team_id=142&teamTabs=transfers", {"HTML", "Data"}]


4

Instead of SendMail make a URLExecute call to the API of an email delivery service such as Mailgun, see my Wolfram Community post Simple inexpensive delivery service outperforms SendMail. The posted example calls CloudDeploy, but you would just be calling the enclosed URLExecute directly from Mathematica.


4

I can understand, if Mathematica does not provide such functionality. It is running on top of an operating system, which delivers all the functionality to do these things, like socket I/O etc. I don't see the point to do this inside of Mathematica. What you can do is this: a) unix plattform Run["/path/to/wget", "http://www.nytimes.com"]; This is just ...


3

If you wanted to do this same kind of parsing for a website for which a built-in function was not available, you could read in the contents of the web page (using URLFetch) and then search this for links, which usually start with "href". For example str = "https://en.wikipedia.org/wiki/Main_Page"; q = URLFetch[str]; ind = ...



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