473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Download a webpage that contains javascript

I am trying to download the html page at

http://www.dreamteamfc.com/dtfc04/se...rList?catidx=1

Using the code

public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1");
BufferedReader webRead = new BufferedReader( new
InputStreamRead er(url.openStre am()));
String line;
while ((line = webRead.readLin e()) != null)
{
System.out.prin tln(line);
}

}
}

But all I am getting is
<HTML><HEAD><SC RIPT
LANGUAGE="JAVAS CRIPT">location .replace("http://www.dreamteamfc .com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replac e("http://www.dreamteamfc .com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.


Any help appeciated!
pat
Jul 17 '05 #1
5 4249
Have you checked its behavious whenyou try opening on Browser..? it
redirects you to someother page and checks if you are logged in.. etc etc..

The way you are doing is not the proper way you have to follow the RFC
for HTTP1.1 for the same... the procedure used by you might work for
some sites but not for all the sites....

Cheers

http://www.ziksa.net
email: sa***@ziksa.net

Patrick wrote:
I am trying to download the html page at

http://www.dreamteamfc.com/dtfc04/se...rList?catidx=1

Using the code

public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1");
BufferedReader webRead = new BufferedReader( new
InputStreamRead er(url.openStre am()));
String line;
while ((line = webRead.readLin e()) != null)
{
System.out.prin tln(line);
}

}
}

But all I am getting is
<HTML><HEAD><SC RIPT
LANGUAGE="JAVAS CRIPT">location .replace("http://www.dreamteamfc .com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replac e("http://www.dreamteamfc .com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.


Any help appeciated!
pat

Jul 17 '05 #2
I had a mistake in my previous post, it should have read:

If I navigate to
http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH
And click on a link which calls the follow javascript function
"javascript:dt_ pop('PostPlayer List?catidx=1&t itle=GOALKEEPER S&gameid=167' ,
'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
A new page pops up, the browser say its url is

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167
Now with my code

public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1");
BufferedReader webRead = new BufferedReader( new
InputStreamRead er(url.openStre am()));
String line;
while ((line = webRead.readLin e()) != null)
{
System.out.prin tln(line);
}

}
}

I can download the page at

http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH
But I cannot download the page at

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167
That the javascript function

"javascript:dt_ pop('PostPlayer List?catidx=1&t itle=GOALKEEPER S&gameid=167' ,
'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
In the page

http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH

calls.

When I try to download

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167

With my code, all i get is

<HTML><HEAD><SC RIPT
LANGUAGE="JAVAS CRIPT">location .replace("http://www.dreamteamfc .com");</SCRIPT></HEAD></HTML>


So how do i go about downloading the contents of the html page that is
in the window that is displayed when the javascript function above is
called?
regards,

pat

Chander <sa***@ziksa.ne t> wrote in message news:<7_******* ************@ne ws20.bellglobal .com>...
Have you checked its behavious whenyou try opening on Browser..? it
redirects you to someother page and checks if you are logged in.. etc etc..

The way you are doing is not the proper way you have to follow the RFC
for HTTP1.1 for the same... the procedure used by you might work for
some sites but not for all the sites....

Cheers

http://www.ziksa.net
email: sa***@ziksa.net

Patrick wrote:
I am trying to download the html page at

http://www.dreamteamfc.com/dtfc04/se...rList?catidx=1

Using the code

public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1");
BufferedReader webRead = new BufferedReader( new
InputStreamRead er(url.openStre am()));
String line;
while ((line = webRead.readLin e()) != null)
{
System.out.prin tln(line);
}

}
}

But all I am getting is
<HTML><HEAD><SC RIPT
LANGUAGE="JAVAS CRIPT">location .replace("http://www.dreamteamfc .com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replac e("http://www.dreamteamfc .com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.


Any help appeciated!
pat

Jul 17 '05 #3
As I menatined earlier read the rfc for http 1.1 when you are requesting
a page firsdt you get is the header you get information for size of the
data to follow, if server has responded as error, what type of error..
or the page is to be redirected, etc.. as per these information you are
to read the following lines or resend the request to the other page as
direction in the header..

Cheers
Patrick wrote:
I had a mistake in my previous post, it should have read:

If I navigate to
http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH
And click on a link which calls the follow javascript function
"javascript:dt_ pop('PostPlayer List?catidx=1&t itle=GOALKEEPER S&gameid=167' ,
'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
A new page pops up, the browser say its url is

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167
Now with my code

public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1");
BufferedReader webRead = new BufferedReader( new
InputStreamRead er(url.openStre am()));
String line;
while ((line = webRead.readLin e()) != null)
{
System.out.prin tln(line);
}

}
}

I can download the page at

http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH
But I cannot download the page at

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167
That the javascript function

"javascript:dt_ pop('PostPlayer List?catidx=1&t itle=GOALKEEPER S&gameid=167' ,
'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
In the page

http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH

calls.

When I try to download

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167

With my code, all i get is

<HTML><HEAD><SC RIPT
LANGUAGE="JAVAS CRIPT">location .replace("http://www.dreamteamfc .com");</SCRIPT></HEAD></HTML>


So how do i go about downloading the contents of the html page that is
in the window that is displayed when the javascript function above is
called?
regards,

pat

Chander <sa***@ziksa.ne t> wrote in message news:<7_******* ************@ne ws20.bellglobal .com>...
Have you checked its behavious whenyou try opening on Browser..? it
redirects you to someother page and checks if you are logged in.. etc etc..

The way you are doing is not the proper way you have to follow the RFC
for HTTP1.1 for the same... the procedure used by you might work for
some sites but not for all the sites....

Cheers

http://www.ziksa.net
email: sa***@ziksa.net

Patrick wrote:
I am trying to download the html page at

http://www.dreamteamfc.com/dtfc04/se...rList?catidx=1

Using the code

public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1");
BufferedReader webRead = new BufferedReader( new
InputStreamR eader(url.openS tream()));
String line;
while ((line = webRead.readLin e()) != null)
{
System.out.prin tln(line);
}

}
}

But all I am getting is
<HTML><HEAD><SC RIPT
LANGUAGE="JA VASCRIPT">locat ion.replace("ht tp://www.dreamteamfc .com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replac e("http://www.dreamteamfc .com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.


Any help appeciated!
pat

Jul 17 '05 #4
Ok, I am starting to understand what is going on now a little better.
I noticed that when I access

http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH

The server sends a cookie. And then when I access

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167

I get the table of players and their respective points.

I used the following code

public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1&title= GOALKEEPERS&gam eid=167");
URLConnection uc = url.openConnect ion();
System.out.prin tln(uc.getHeade rField("Set-Cookie"));
}
To get the cookie, which was

CF_HA=241567669 8; Domain=.dreamte amfc.com; expires=Tue, 14-Sep-04
22:25:46 GMT; Path=/

I think
CF_HA, is just a unique identifier, a variable which in incremented
by the server for each new client
Domain, is just the domain
expires, is just the expiry date
Path, hmm dunno

Now I hardcoded the cookie into the code, with a valid expiry date

public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1&title= GOALKEEPERS&gam eid=167");
URLConnection uc = url.openConnect ion();

String cookie = "CF_HA=24156766 98; Domain=.dreamte amfc.com;
expires=Tue, 14-Sep-04 22:25:46 GMT; Path=/";
uc.setRequestPr operty("cookie" ,cookie);
int i = 0;

while ((i = uc.getInputStre am().read()) != -1)
{ System.out.prin t((char) i);
}
}
Now, when I run this code I get the following error
Exception in thread "main" java.io.IOExcep tion: Server returned HTTP
response code: 400 for URL:
http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167
at sun.net.http://www.protocol.http.HttpURLConn...tion.java:1133)
at Test.main(Test. java:46)
Is the following method

uc.setRequestPr operty("cookie" ,cookie);

The correct way to send the cookie to the server?
Any pointers on what I should try next, I'm not quite sure where to
look.
pat

Chander <sa***@ziksa.ne t> wrote in message news:<aK******* **************@ news20.bellglob al.com>...
As I menatined earlier read the rfc for http 1.1 when you are requesting
a page firsdt you get is the header you get information for size of the
data to follow, if server has responded as error, what type of error..
or the page is to be redirected, etc.. as per these information you are
to read the following lines or resend the request to the other page as
direction in the header..

Cheers

Jul 17 '05 #5
On 15 Sep 2004 07:38:22 -0700, go***********@y ahoo.co.uk (Patrick)
wrote:
Ok, I am starting to understand what is going on now a little better.
I noticed that when I access

http://www.dreamteamfc.com/dtfc04/se...nguage=ENGLISH

The server sends a cookie. And then when I access

http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167

I get the table of players and their respective points.

I used the following code

public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1&title= GOALKEEPERS&gam eid=167");
URLConnection uc = url.openConnect ion();
System.out.prin tln(uc.getHeade rField("Set-Cookie"));
}
To get the cookie, which was

CF_HA=241567669 8; Domain=.dreamte amfc.com; expires=Tue, 14-Sep-04
22:25:46 GMT; Path=/

I think
CF_HA, is just a unique identifier, a variable which in incremented
by the server for each new client
Domain, is just the domain
expires, is just the expiry date
Path, hmm dunno

Now I hardcoded the cookie into the code, with a valid expiry date

public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc .com/dtfc04/servlet/PostPlayerList? catidx=1&title= GOALKEEPERS&gam eid=167");
URLConnection uc = url.openConnect ion();

String cookie = "CF_HA=24156766 98; Domain=.dreamte amfc.com;
expires=Tue, 14-Sep-04 22:25:46 GMT; Path=/";
uc.setRequestPr operty("cookie" ,cookie);
int i = 0;

while ((i = uc.getInputStre am().read()) != -1)
{ System.out.prin t((char) i);
}
}
Now, when I run this code I get the following error
Exception in thread "main" java.io.IOExcep tion: Server returned HTTP
response code: 400 for URL:
http://www.dreamteamfc.com/dtfc04/se...ERS&gameid=167
at sun.net.http://www.protocol.http.HttpURLConn...tion.java:1133)
at Test.main(Test. java:46)
Is the following method

uc.setRequestPr operty("cookie" ,cookie);

The correct way to send the cookie to the server?
Any pointers on what I should try next, I'm not quite sure where to
look.
pat

Chander <sa***@ziksa.ne t> wrote in message news:<aK******* **************@ news20.bellglob al.com>...
As I menatined earlier read the rfc for http 1.1 when you are requesting
a page firsdt you get is the header you get information for size of the
data to follow, if server has responded as error, what type of error..
or the page is to be redirected, etc.. as per these information you are
to read the following lines or resend the request to the other page as
direction in the header..

Cheers

Well, I agree with Chander that you need to read the RFC on HTTP 1.1
(RFC 2068) which can be found at
http://www.ietf.org/rfc/rfc2068.txt?number=2068. I'd give you more
detailed advice, but I think a lot of it would be speculation (my
programmer friend is sitting next to me, so these are his words)

So here is the speculation. The issue that might be the cause of your
woes. In order for you to set properties in a URLConnection, the
properties MUST be set before you call getInputStream( ) or getHeader()
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
20529
by: Michael | last post by:
I am trying to allow a user to view a PDF in a new window. I currently have this working using the following: <a href="./pdf.do?parameter=01121980" target="top"><b>pdf</b></a> The problem with the above solution is the back/forward buttons and all the other browser options. Because of this, I am trying to get the following solution to...
2
1992
by: Tom Youngquist | last post by:
I am trying to download a text file that my .NET page has just created based on entered parameters on the web page. Everything seems to work and the file is created. I am using the following code to start the download process: Response.Clear() Response.ContentType = "text/plain" Response.AppendHeader("Content-Disposition", "attachment;...
1
3023
by: Alex | last post by:
Hi, Everyday, I download data from a webpage and manually input data into my MS Access database. I am thinking of automate the routine by a VB script. The webpage I am visiting will return a csv file, with only one row. In this row, there are several columns of data. I would like to add these data as a NEW row in my data base.
0
1940
by: Ron Vecchi | last post by:
Hello, Through using this and many other Microsoft dotnet newsgroups I have been pointed towards many helpful open source projects and articles that have helped a great deal in my studies as well as projects. Recently I have been using a lot of Macromedia Flash Movies within my asp.net pages, as many people have. For those familiar with...
13
13655
by: Jitendra | last post by:
Hi! I m facing a problem with 'javascript:void(0)' Software Environ:- IE: 6.0.2600.0000 OS: Windows 2000 Professional with Service Pack 4 Problem:- I have a webpage with several links (<A> tags), now i have added onClick and blocked HREF using 'javascript:void(0)' as below:-
6
2505
by: eureka | last post by:
Hi friends, I am developing a web application using Jsp and JS. I have a main Jsp page(Jsp1).Inside it I have an iframe having an Html- table which is created dynamically and contains all records from the backend-table . For creating this dynamic table I've used another Jsp(Jsp2) and in Jsp1 I say: <iframe id = "I1" src="Jsp2.jsp"...
3
1438
by: Gargoyle | last post by:
I am curious to know if any research has been conducted regarding the efficiency of having a single (large) .js file downloaded for a webpage compared to several smaller .js files. For example in my web pages I often include the scripting code <script language="javascript" type="text/javascript" src="ascript.js"></script> which contains...
3
1274
by: kyle | last post by:
Hi Guys, I am trying to mimic the behavior of download.com... where a page says "your download will start in 10 seconds" and then the download box pops up. Would anyone mind telling me how that works? I want to use this as an alternative to "click here to download the file" and then directly link to the file. Any help is appreciated. ...
1
1679
by: Rakhi | last post by:
hello i want to alter the download settings of mozilla firefox browser using javascript of my application !! wat is happenin in my application is, on calling a method , it make a file ready to be downloaded . and the browser gives the download window ,like.., save file or open file etc.. as we generally see. i want the browser to ask...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.