Tag Info

Hot answers tagged

14

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.


11

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


10

The reason your approach fails is because Cases works slightly differently than what you've intended in the question. Cases does a depth-first scanning and once it finds its first match, it transforms it and starts traversing the tree backwards, looking for other matches. Consider this simple example: list = {p[1, 2], q, {p[3, 4], p[5, p[6, 7]]}}; ...


6

Update I have found a new method for converting numeric strings using an internal function that was previously unknown to me. It is quite flexible, but its use requires care as bad input will crash the kernel. I have detailed my present understanding of the function here: ParseTable syntax. Does this work for you? hexNodeData /. XMLElement[a_, {}, ...


5

Mathematica does match all instances. There is, however, one XMLElement (current_observation) that contains all other XMLElements. So after the deepest XMLElements are matched MMA goes one step up and matches the containing XMLElement, which is then returned, and it shows the other XMLElements. A simple example: Cases[ {XMLElement["test", "BlahBlah", ...


4

I have found the solution. From the Documentation, Some documents use names in a non-namespace-compliant fashion, because the XML namespace recommendation, which extends XML, was made after the initial XML recommendation. "IncludeNamespaces"->"Unparsed" is provided to allow parsing of these documents. The name is always represented as the ...


3

As the result of the RSS is just a notebook expression, you can perform any transformation of that expression before you show the notebook. Here I replace the buttonbox as which the hyperlink is represented with a graphics cell that shows the image: blognb = Import[ "http://gregmankiw.blogspot.com/feeds/posts/default?alt=rss", "RSS"]; blognb /. { ...


2

Seems to work fine for me. I placed a simple RTF file (created by TextEdit on my Mac) on my webspace so you can try it. NotebookPut[ Import["http://facstaff.unca.edu/mcmcclur/temp.rtf"] /. Cell[td_TextData, "Input", opts___] -> Cell[td, "Text", opts], WindowTitle -> "ImportedRTF.nb"]; The one problem I did have was that the resulting ...



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