473,799 Members | 3,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing the javascript on a webpage using Webrequest/Webresponse

Hi,

I'm using the following code to request the html source from the
quoted site.

......
string url = "http://www1.soccerstan d.com/";
WebRequest webRequest = WebRequest.Crea te(url);
WebResponse webResponse = webRequest.GetR esponse();
beginStr = new StreamReader(we bResponse.GetRe sponseStream(),
Encoding.Defaul t).ReadToEnd();
webResponse.Clo se();
......

This returns me a string of HTML as expected.

If I go to the website in an IE browser and View Source I see some
Javascript.

I want the webResponse string to return the javascript that I can see
in the browser script.

Can anyone help.

Thanks
Gavin
Nov 16 '05 #1
2 9705
Hi,

Your code snippet gives you exactly what the remote web server produced as
the web page contents. If you see script in the IE source, the script is
most likely also in the returned HTML string. The only exception I can think
of is when the initial portion of the script adds further script to the page
through DHTML object model.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

<gi***@consulta nt.com> wrote in message
news:de******** *************** ***@posting.goo gle.com...
Hi,

I'm using the following code to request the html source from the
quoted site.

.....
string url = "http://www1.soccerstan d.com/";
WebRequest webRequest = WebRequest.Crea te(url);
WebResponse webResponse = webRequest.GetR esponse();
beginStr = new StreamReader(we bResponse.GetRe sponseStream(),
Encoding.Defaul t).ReadToEnd();
webResponse.Clo se();
.....

This returns me a string of HTML as expected.

If I go to the website in an IE browser and View Source I see some
Javascript.

I want the webResponse string to return the javascript that I can see
in the browser script.

Can anyone help.

Thanks
Gavin


Nov 16 '05 #2
gi***@consultan t.com wrote:
Hi,

I'm using the following code to request the html source from the
quoted site.

.....
string url = "http://www1.soccerstan d.com/";
WebRequest webRequest = WebRequest.Crea te(url);
WebResponse webResponse = webRequest.GetR esponse();
beginStr = new StreamReader(we bResponse.GetRe sponseStream(),
Encoding.Defaul t).ReadToEnd();
webResponse.Clo se();
.....

This returns me a string of HTML as expected.

If I go to the website in an IE browser and View Source I see some
Javascript.

I want the webResponse string to return the javascript that I can see
in the browser script.


I guess the page checks the user agent. Try pretending to be some
browser, like

webRequest.User Agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE;
rv:1.7.5) Gecko/20041108 Firefox/1.0";

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 16 '05 #3

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

Similar topics

1
2367
by: John | last post by:
I am in need to find a way to get the HTML from an internal URL. For example: I have page : default.aspx?page=Test, I need to get HTML of that page after rendering. At first thought, I would use WebRequest to make a requestion, then use WebResponse to get the HTML. However, it won't work in my situation. The resaon for that is: WebRequestion needs a URI, which is in the format of http://<MyDomainName>/deafult.aspx?page=Test ... In my...
9
1960
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have the appropriate session cookie already. After logging in on that page successfully they are given the cookie and redirected back to the page they initially tried to go to. I would like to create a Windows application that gets data from that...
0
2220
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't seem to make it work. Please point out the mistakes that I have. Thanks code............. WebRequest = WebRequest.Create(URL) WebRequest.Timeout() = RunInfo.ConnectTimeout WebResponse = WebRequest.GetResponse 'WEBRESPONSE IS A PUBLIC OBJECT...
3
3692
by: Loane Sharp | last post by:
Hi there I use the FileStream object to download a zip file over the internet to my local disk. The file downloads successfully, but when I attempt to unzip it, I'm told that the file is in use by another process. This occurs even if I release the object using fs.Close() and fs = Nothing. Please help (my code is given below) Best regards
4
1910
by: Savas Ates | last post by:
I have a vb.net web application. I want to post some variables to another web page and take some values back and process them. This is codes in my target url. I should post "langpair" cariable to my target url and it will respond with a value depend on a value which i send. <SELECT name=langpair><OPTION value=en|de>English to German</OPTION><OPTION value=en|es>English to Spanish</OPTION> </select>
2
5977
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an application to download images using System.NET classes (webclient, webrequest) asynchronously behind proxy server. The reading method works like this: System.Net.WebClient client=new System.Net.WebClient();
3
3743
by: Gina_Marano | last post by:
Hey All, I need to download 1 or more files from a secure or unsecure website folder using HTTP. Here is what I have so far: public void GetHTTPImages() { WebClient HTTPClient = new WebClient();
0
928
by: Rama Jayapal | last post by:
i have used the following code string html = "http://monsterindia.com/"; System.Net.HttpWebRequest webrequest = (HttpWebRequest)System.Net.WebRequest.Create(html); System.Net.HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse(); StreamReader webstream = new StreamReader(webresponse.GetResponseStream(), Encoding.UTF8); webrequest.Method = "GET"; string strml =...
0
1247
by: Jeff | last post by:
hey asp.net 3.5 I'm developing a webportal which need to access a webpage of a external system. The external webpage contain a table which I want to retrieve the values from.. it is a html table my first aproach is to do like the code below, and then use several if-statement to get the results I want:
0
9687
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6805
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.