Search code examples
javascriptiphoneobjective-ciosasihttprequest

iPhone app: getting data without a web API


I am attempting to create a simple iOS application, mostly for the learning process, but one which might also be useful to other botanists. The California Native Plant Society has a new Rare plant database online. At first I would like to just do simple querys for a plant by name. Later adding some type of location search, finding known occurrences of rare plants in your specific area.

So a search for `Layia' brings us to a page with a table. Looking at the source for the page I believe the table is generated by:

<div class="breadcrumb top20">
<div class="line1 center">
<!--    <a href="/advanced.html" class="ret_search">Modify Search Criteria</a> -->
<span id=modifyCriteriaSlot></span>
&nbsp;
<span id=exportPdfSlot></span>
&nbsp;
<span id=exportExcelSlot></span>
&nbsp;
<!-- END line1 -->

<span id=modifyColumnsSlot></span>
&nbsp;
<span id=sortSlot></span>
&nbsp;
<span id=displayPhotosSlot></span>
</div>
<!-- END line1 -->
</div>

I guess I am stuck. As far as the app goes I have been playing around with ASIHttpRequest and I see references to XMLKiss to parse web pages, but I just don't see any data on this page TO parse, it seems to be generated else ware and then just appears? I know I am a little out of my element here, but I want to put in the time and learn what I need to, so a little direction would be an awesome help! Thanks.


Solution

  • If it helps, they are showing the results table with this DIV

    <div id=resultListSlot align=center style="max-width: 960px;"></div>
    

    The DIV is being populated with javascript. The JS can be found here:

    http://www.rareplants.cnps.org/org.cnps.Result/org.cnps.Result.nocache.js

    Im not sure how you can get that to reply to your own request... let me look at it when I get back later today to see if I can help even more.

    --------- Update -----------

    If you wanted to skip learning JS you could just use firefox to view the DOM source which will include all the HTML generated by the JS. I just did a search for ALL of their plants, CTRL+A to select all of the page, right click on a highlighted area and "view selection source".

    Then you could host your own page like I have done. Look at this page here http://luistovar.com/plants.html

    Now you have all the plants, the HTML, the links and everything you need to create your own list. The only downfall is you would have to update every few weeks?? or so. It all depends on how often their data changes, or how much an updated list matters to you.
    Might be better than learning JS though.