views:

28

answers:

2

Is it possible to redirect a web apps results to a second application? I cannot parse the html source. It contains the javascript functions that execute the queries but all the content is probably server side.

I hope this makes sense. The owner has made the script available but I am not sure how this helps. Can I using .net call the site and redirect results perhaps to a file or database?

the app accesses one of googles apis and performs searches/queries and returns results which are displayed on the site. Now all the javascript functions that perform these queries are listed in the source but I do not know javascript so it does not make much sense to me. I have used the documentation which uses the oauth protocol to access the api and have implemented that in my web app but it took me nearly a week to get the request token right and now to send requests to the api, sometimes I get one result back and sometimes none. It is frustrating me and the owner of the web app has given use of his script but he says all that happens is that my browser interacts with the google api and not his server.

So I thought why not have my web app call his, since his interacts with the API flawlessly and have the results sent to my app to save in a database.

I have very little experience here so pardon my ignorance

+1  A: 

If you don't want to learn the Google APIs, you could load that page in a minimized inline frame and then grab the results from it with JavaScript. It will be a lot of coding on your behalf, but it's doable. So, it's just to bite the sour apple and learn JavaScript. ;)

Gert G
so the inline frame loads the results in somewhat of an extractable form? Will I be able to then parse the xml? Thank you so much for your response. I am starting to look into javascript; dont mind learning new stuff.
vbNewbie
His JavaScripts generates the results in HTML, correct? If that's the case, you can grab the data from his page (that's in the iframe). You would need to do a lot of coding to do this (essentially parsing his results table or whatever he has used to build the results), but as I said... it's doable. The biggest issue of doing this is that your code will break if he ever change the structure of the results. You would be better off learning the Google APIs and write your own code, but I understand that you're not at that level yet.
Gert G
If you're more comfortable parsing HTML on your server, you could send the generated HTML with an AJAX call to your server and parse it there. But yet again, you need to write some JS to do this.
Gert G
thank you. Appreciate it
vbNewbie
No problem. I hope you can get a solution in place.
Gert G
A: 

It sounds like Application1 needs to call a URL on Application2, and do something with the results.

You can use WebClient:

Public Sub GetUrlContents(URL As String ) 'call this method using Application2's URL

    ' Get HTML data
  Try
    Dim fileReader As New WebClient()
    Dim byteArray As Byte()
    Dim addr As Uri
    Dim content As String

    addr = New Uri("http://www.foo.com/") //use URL in param list instead.
    byteArray = fileReader.DownloadData(addr)
    content = System.Text.Encoding.ASCII.GetString(byteArray)

    'save to file or database instead.
    Console.WriteLine(content)

  Catch ex As HttpListenerException
     Console.WriteLine("Error accessing site " + ex.Message)
  Catch ex As Exception
     Console.WriteLine("Error accessing site " + ex.Message)
 End Try


End Sub
p.campbell
but the results are not there when I look in the page source so how would I get the content using webclient. When I look at the page source all that is there is the javascript functions.
vbNewbie