Greetings,
It seems to be puzzle for me but I am sure such kind of requests could
have been handled and addressed. This is my requirement:
Manual Steps currently followed:
1. Supply the ISBN number and click OK
2. the web page returns list of books (if the ISBN number is partly
entered)
3. click on the desired list
4. the web page returns the details of the book like book name, etc
We have a requirement to validate around 50000 ISBN and doing it
manually will be laborious. Hence I thought it could be automated.
This was my approach:
1. Create URL String with Post data
2. open the URLConnection
3. read the returned web page and get the total count of books
returned
4. create another URL string and open the url connection
5. read the web page and parse the details
Until Point 3, I was able to accomplish. However, when another
connection was established, the returned page was session expired.
I should bascially use the same URL object to repost or redirect to
the server with my second URL. Not sure how I could accomplish
Please help!
The code snippet which is abridged version.
final String URL1 = "http://www.google.com?isbn=123
&startrow=1&endrows=10"
final String URL2= "http://www.google.com?whichrow=1"
...
...
URL url = new URL (url1);
URLConnection urlconn = url.openConnection ();
urlconn.setDoOutput(true);
urlconn.setUseCaches(false);
urlconn.setRequestProperty("Content-Type", "application/x-www-form-
urlencoded");
readContents ();
url = new URL (url2);
urlconn = url.openConnection ();
...
parsehtml()
Dev - 14 Feb 2008 16:15 GMT
> Greetings,
>
[quoted text clipped - 32 lines]
>
> final String URL2= "http://www.google.com?whichrow=1"
> ...
> ...
> URL url = new URL (url1);
urlconn.setDoOutput(true);
urlconn.setUseCaches(false);
urlconn.setRequestProperty("Content-Type", "application/x-www-form-
urlencoded");
readContents ();
url = new URL (url2);
urlconn = url.openConnection ();
...
parsehtml() -> returns session expired.
Any insight on how to repost the second url using the same
URLconnection?
Thank you,
Dev
GArlington - 14 Feb 2008 17:02 GMT
> > Greetings,
>
[quoted text clipped - 52 lines]
> Thank you,
> Dev
Why do you need to access the data in your url2 as ?whichrow ?
Why can not you get and use full ISDN from that row?
GArlington - 14 Feb 2008 17:03 GMT
> > > Greetings,
>
[quoted text clipped - 55 lines]
> Why do you need to access the data in your url2 as ?whichrow ?
> Why can not you get and use full ISDN from that row?
Was meant to read ISBN, NOT ISDN...
Dev - 14 Feb 2008 17:26 GMT
Hi,
It is becuase that's how the external website is designed. To provide
you better insight with the example given earlier:
1. point to the website and key-in the postal code
2. the webserver will return a list of all books for a ISBN (single)
or matching ISBN numbers (multiple)
3. From the list, the user could narrow down and click on his interest
4. This again is posted to webserver and the details of the ISBN is
returned.
Hope this answers your question.
-Dev