Getting text information from the Internet into my app - objective-c

I learning Objective C, and I am going to develop some apps. I have a general question: How to get text information from the Internet into your app. Say you want the current title of Yahoo News. Do I need to use some PHP, or are there Objective-C specific classes to choose from?
Help is appreciated (code as well!), just anything that can help me take te step to exploring the new possibilities!

If I understand your question, I'd say the best way to do it would be to get the HTML source from the URL of your choosing as a string, then parse it to grab an attribute such as the title. Have a look at NSString and NSXMLDocument; they both let you instantiate them from a URL.

Here's a great way to do it:
Go to Yahoo Pipes, and create your "pipe" (basically a feed of one or many different data inputs on the web).
Publish: Select a format for Yahoo to host, for example as an RSS feed or in JSON.
UIWebView can then point to your pipe's URL. (Here's a tutorial on UIWebView)
Done.
Note that you can choose to get the feed as RSS, JSON, and other formats as well. Here is an example of a pipe I set up for the National Vulnerabilities Database as RSS, and the same feed as JSON.

ASIHttpRequest Will keep you sane.

Related

Pulling data, mainly text from websites

I'm fairly new to programming in general but I have delved into vb.net recently. I was looking into how to grab data from a website but don't fully comprehend how to or through what means.
My main end game is to just pull data for a lack of better word. Say for instance, a website shows text, I'd like to be able to pull that text into my program using vb.net. Is that possible?
I don't know how to use javascript, php and know only little of html/css. I'm of course willing to learn but I haven't had much luck searching for this specific information or solution. Without access to the websites database, is there another way for my app to read the website for what it would be displaying and retrieve this information? I'm mainly concerned with text, no other information is really needed. From what i've gathered, the information is tagged by something like an ID, or class? Any help would be appreciated.
Web servers essentially have 2 operations, POST, which is you sending something to the website, and GET, which is you requesting something from the website.
For the most part you can just do a GET of some sort on the website and it'll return what you request in a data format, likely JSON. You can often look for fields based on CSS selectors in the web page itself. Though, there are other ways and some HTTP libraries may return the data to you in various formats, mainly JSON and XML.
I'd suggest right click->view source on a web page to learn more about how they're structured. As for how to do a GET in javascript on some website, this code would grab the website at the URL you give it.
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); //the get request
xmlHttp.send( null );
return xmlHttp.responseText; //the website data in XML format.
}

Find all Delicious posts using Yahoo! Pipes from ALL users

I'd like to try to create a Yahoo Pipe that will return ALL of the articles, urls, and # of saves on Delicious which are tagged with the category, for instance, 'sushi'.
Is that possible? (I know I can do it with my own tags, or with those in my network. And I know I can simply go to Delicious and push the load more button until I exhaust the list.)
But a json structure or an XML output file would be so much easier to process.
Would anybody have a clue how to get this?
In order to access delicious data in your application, you’ll need to get a Yahoo! API key and configure it to use delicious social bookmarking. You can do this by creating a project for your application. https://developer.apps.yahoo.com/dashboard/createKey.htmlThere are examples at this second link showing something similar to what you are trying to do.
Read more here:
http://developer.yahoo.com/delicious/

How to parse information from blog to iphone?

could someone point me in the right direction in how i can parse data from a blog to an iphone. E.g. You have a table view displaying the posts of the blog, you select a table cell and text content is displayed. Are there any tutorials/examples on this?
I have a bit of experience with parsing data using JSON (parsed data from database to iphone) but unsure on where to start with this?
Thanks for an help..
What you want to do is use the Wordpress API. The flow goes like this:
Make an API call. This is a subject unto itself, but typically you'd use NSHTTPRequest and NSURLConnection to make the request.
Parse the result. I forget if you get XML back; you probably do; in that case there are tons of solutions for parsing, including NSXMLParser and libxml2.
Populate UITables, etc. with the retrieved information.
The Wordpress API is not that big or complex, but it's a bigger subject than I can really get into in the context of an SO answer, so I'll just refer you to the aforelinked documentation and wish you happy reading.

Apple Appstore name search via the API?

Is it possible to do a search for apps by title via the API? For example, the equivalent of "Return a list of apps (if any) with the word 'dog' in the title".
I've seen two access points that come close, but don't seem to offer this:
The RSS feed; it lists apps, but apparently only groupings like, "top 100..."
The query interface; but it doesn't seem to query over the app media type. (?)
I found the answer. Although not explicitly documented, it's possible to search by app name.
http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html
You're right, it wasn't very clear on that iTunes page at all. The parameter entity=software is the key. For example, here's a search for my app, TypeLink:
http://itunes.apple.com/search?entity=software&term=typelink&callback=myCallbackFunction
If you're wondering what the callback is for, here's some more info on the JSONP format it uses:
http://en.wikipedia.org/wiki/JSONP
For any future person who wants to link to the App Store keyword search result page directly from a web link - this format works as of April 2013:
http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&submit=media&term=KEYWORD%20GOES%20HERE
Was a PITA to figure out but finally got the syntax right... Needed this because a client has apps made by multiple developers so I couldn't just use the suggested Appstore.com/DeveloperName link to return all their apps.
Thanks all for sharing wisdom. Hope this helps someone.

How can I get the full change history for an article on Wikipedia?

I'd like a way to download the content of every page in the history of a popular article on Wikipedia. In other words I want to get the full contents of every edit for a single article. How would I go about doing this?
Is there a simple way to do this using the Wikipedia API. I looked and didn't find anything the popped out as a simple solution. I've also looked into the scripts on the PyWikipedia Bot page (http://botwiki.sno.cc/w/index.php?title=Template:Script&oldid=3813) and didn't find anything that was useful. Some simple way to do it in Python or Java would be the best, but I'm open to any simple solution that will get me the data.
There are multiple options for this. You can use the Special:Export special page to fetch an XML stream of the page history. Or you can use the API, found under /w/api.php. Use action=query&title=$TITLE&prop=revisions&rvprop=timestamp|user|content etc. to fetch the history.
Pywikipedia provides an interface to this, but I do not know by heart how to call it. An alternative library for Python, mwclient, also provides this, via site.pages[page_title].revisions()
Well, one solution is to parse the Wikipedia XML dump.
Just thought I'd put that out there.
If you're only getting one page, that's overkill. But if you don't need the very very latest information, using the XML would have the advantage of being a one-time download instead of repeated network hits.