Search code examples
cordovaweb-scrapingphonegap-pluginscordova-plugins

Extract text from Website with Cordova


I'm developing a mobile application and I would like to extract a text value from a website which is not mine using Cordova, I googled but I could not find a valid example. Is there a plugin to do that?

I could not do this with Ajax because of the access orgin policy .

Thank you


Solution

  • Possible approaches:

    • Use the inAppbrowser to load the page and run your script in that page to extract elements required using cross-browser communication. Read this article which explains how to do it.
    • Load the page in ajax call and parse the response based on markers using regex or convert the response to a HTML tag using this API and query DOM via JS API. Read this interesting article on web scraping in Hybrid app explained by Ashteya Biharisingh
    • Use the library JSDOM which runs on Node.js server. By using this lib you can load the web page inside a NodeJS environment and extract the dom parts using popular Jquery API. This requires a intermediate server and off load the scraping logic.