简体   繁体   中英

Screen Scraping a Database

I've been searching for help with screen scraping for the windows phone 7 but cannot find any help relevant to what i want. The basis of my application is to take a phone number typed in an input box on the device -> pass it to a website's searchbox -> search the website's SQL database -> pass the raw results back to the phone and display them in a table.

I have permission from the website owner to use his online database for this purpose.

Is this possible and, if so, how would I go about doing this?

Thanks in advance!

EDIT: After some extra research I've found that with using the POST method I can send the data needed to the search box on the website and the results are successfully found but I am unsure on how to display the results onto the application itself? I know the data is successfully sent via packets viewed in WireShark. Thanks again.

Code for POST:

        InitializeComponent();
        Dictionary<string, object> parameters = new Dictionary<string, object>();
        parameters.Add("search_name", "Google"); //Test Search
        parameters.Add("submit", "Search");
        PostClient proxy = new PostClient(parameters);
        proxy.DownloadStringCompleted += (sender, e) =>
        {
            if (e.Error == null)
            {
                //Process the result...
                data = e.Result;
            }
        };
        proxy.DownloadStringAsync(new Uri("http://www.SITE.com/search.php", UriKind.Absolute));
        webBrowser1.Navigate(new Uri(, UriKind.Absolute));`

As far as I know it is not possible/allowed to access other applications running on the Windows Phone.

So this is not possible unless the publishers of the other applications connect to your website/webservice.

NB: When Windows Phone 8 come out and it is the same as or similar to Windows 8 there might be contracts available that allow the wiring up of application like this. (This is just guessing)

Rather than using the website's UI and screen scraping the results, I would create an HTTP request similar to or the same as the request generated by the web page (this will probably be a POST request containing form data). I would then send this to the web server and use something like HtmlAgilityPack to parse the required data from the response.

Effectively, the website presents you with an HTTP API using HTML as the message format. Use this directly, rather than using a client side rendering of these messages, which ultimately is designed for user interaction rather than code interaction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM