Hi,,
Can anyone tell me how to log on to a internet website with username and
password, navigate to other subpages on that site, and then start downloading
a textfile to disk??
Thanks 10 1399
Here's a snip from a web spider I wrote last year:
<snip>
Private Function getHtml(ByVal i As Integer) As String
Dim url As String = "http://www.wtng.info/wtng-" & Chr(i) & Chr(i) &
".html"
Dim reader As StreamReader
Dim html As String
Try
reader = New StreamReader( _
CType( _
CType( _
WebRequest.Create(url), _
HttpWebRequest).GetResponse(), _
HttpWebResponse).GetResponseStream())
html = reader.ReadToEnd()
reader.Close()
Catch ex As Exception
Try: reader.Close(): Catch exc As Exception: End Try
html = ""
Console.WriteLine("Could not connect to " & url)
End Try
Return html.Trim()
End Function
</snip>
--
Peace & happy computing,
Mike Labosh, MCSD
"Musha ring dum a doo dum a da!" -- James Hetfield
"Henrik" <He****@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com... Hi,,
Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
Thanks
Here's a snip from a web spider I wrote last year:
<snip>
Private Function getHtml(ByVal i As Integer) As String
Dim url As String = "http://www.wtng.info/wtng-" & Chr(i) & Chr(i) &
".html"
Dim reader As StreamReader
Dim html As String
Try
reader = New StreamReader( _
CType( _
CType( _
WebRequest.Create(url), _
HttpWebRequest).GetResponse(), _
HttpWebResponse).GetResponseStream())
html = reader.ReadToEnd()
reader.Close()
Catch ex As Exception
Try: reader.Close(): Catch exc As Exception: End Try
html = ""
Console.WriteLine("Could not connect to " & url)
End Try
Return html.Trim()
End Function
</snip>
--
Peace & happy computing,
Mike Labosh, MCSD
"Musha ring dum a doo dum a da!" -- James Hetfield
"Henrik" <He****@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.com... Hi,,
Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
Thanks
"Henrik" <He****@discussions.microsoft.com> schrieb: Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
\\\
Dim w As New WebClient()
w.Credentials = New NetworkCredential("username", "password")
w.DownloadFile(...)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Henrik" <He****@discussions.microsoft.com> schrieb: Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
\\\
Dim w As New WebClient()
w.Credentials = New NetworkCredential("username", "password")
w.DownloadFile(...)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Hi Mike,,
Thanks for you reply,, But it's not quite that im looking for?
I want to connect to a site, where in need to type in my username and
password on a form and submit this form. After valid check i get a new page,
where i can download a ".txt"-file. And it's this file im interesed in..
I've got the download procedure to work just fine by using a
"WebClient1"-component.. But my main problem is the logon-procedure to the
site. I've tried this:
Dim w As New WebClient
w.Credentials = New NetworkCredential("username", "password")
w.DownloadFile("https://Reports/xx/xxx.TXT", "c:\xxx.TXT")
It's saves a file,, but its the logonpage??
"Mike Labosh" wrote: Here's a snip from a web spider I wrote last year: <snip> Private Function getHtml(ByVal i As Integer) As String
Dim url As String = "http://www.wtng.info/wtng-" & Chr(i) & Chr(i) & ".html" Dim reader As StreamReader Dim html As String
Try reader = New StreamReader( _ CType( _ CType( _ WebRequest.Create(url), _ HttpWebRequest).GetResponse(), _ HttpWebResponse).GetResponseStream())
html = reader.ReadToEnd() reader.Close()
Catch ex As Exception Try: reader.Close(): Catch exc As Exception: End Try html = "" Console.WriteLine("Could not connect to " & url) End Try
Return html.Trim()
End Function </snip>
-- Peace & happy computing,
Mike Labosh, MCSD "Musha ring dum a doo dum a da!" -- James Hetfield "Henrik" <He****@discussions.microsoft.com> wrote in message news:70**********************************@microsof t.com... Hi,,
Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
Thanks
Hi Mike,,
Thanks for you reply,, But it's not quite that im looking for?
I want to connect to a site, where in need to type in my username and
password on a form and submit this form. After valid check i get a new page,
where i can download a ".txt"-file. And it's this file im interesed in..
I've got the download procedure to work just fine by using a
"WebClient1"-component.. But my main problem is the logon-procedure to the
site. I've tried this:
Dim w As New WebClient
w.Credentials = New NetworkCredential("username", "password")
w.DownloadFile("https://Reports/xx/xxx.TXT", "c:\xxx.TXT")
It's saves a file,, but its the logonpage??
"Mike Labosh" wrote: Here's a snip from a web spider I wrote last year: <snip> Private Function getHtml(ByVal i As Integer) As String
Dim url As String = "http://www.wtng.info/wtng-" & Chr(i) & Chr(i) & ".html" Dim reader As StreamReader Dim html As String
Try reader = New StreamReader( _ CType( _ CType( _ WebRequest.Create(url), _ HttpWebRequest).GetResponse(), _ HttpWebResponse).GetResponseStream())
html = reader.ReadToEnd() reader.Close()
Catch ex As Exception Try: reader.Close(): Catch exc As Exception: End Try html = "" Console.WriteLine("Could not connect to " & url) End Try
Return html.Trim()
End Function </snip>
-- Peace & happy computing,
Mike Labosh, MCSD "Musha ring dum a doo dum a da!" -- James Hetfield "Henrik" <He****@discussions.microsoft.com> wrote in message news:70**********************************@microsof t.com... Hi,,
Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
Thanks
Hi Herfried,,
Thanks for replying :o)
I have tried that?,, it only takes me to the loginform with the username,
password and submitbutton :o(.. And i have even tried to write in the whole
url to the file, but still no luck??
Do i really have to "fill" in username and password and make the
submit-action programly instead?? and the call the url with the file to
download afterwards?
Thanks
"Herfried K. Wagner [MVP]" wrote: "Henrik" <He****@discussions.microsoft.com> schrieb: Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
\\\ Dim w As New WebClient() w.Credentials = New NetworkCredential("username", "password") w.DownloadFile(...) ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Hi Herfried,,
Thanks for replying :o)
I have tried that?,, it only takes me to the loginform with the username,
password and submitbutton :o(.. And i have even tried to write in the whole
url to the file, but still no luck??
Do i really have to "fill" in username and password and make the
submit-action programly instead?? and the call the url with the file to
download afterwards?
Thanks
"Herfried K. Wagner [MVP]" wrote: "Henrik" <He****@discussions.microsoft.com> schrieb: Can anyone tell me how to log on to a internet website with username and password, navigate to other subpages on that site, and then start downloading a textfile to disk??
\\\ Dim w As New WebClient() w.Credentials = New NetworkCredential("username", "password") w.DownloadFile(...) ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
I have the exact same problem.
I need to download the csv file from Google AdSense.
Google requires the name and password to be send using "POST" method.
This code (below) will only download the html content of the page, but
if url points to file it doesn't do anything. Can someone amend this
code to work for files as well?
Public Function GetPageHTML(ByVal URL As String) As String
Dim myWebClient As New WebClient
Dim myNameValueCollection As New NameValueCollection
myNameValueCollection.Add("username", "joedoe")
myNameValueCollection.Add("password", "123456")
Dim responseArray As Byte() = myWebClient.UploadValues(URL,
"POST", myNameValueCollection)
GetPageHTML = Encoding.UTF8.GetString(responseArray)
End Function
Fixed my problem by doing this:
Dim Request As HttpWebRequest
Dim Response As HttpWebResponse
Dim URL As String = "https://login.form"
Dim Params As String = "action=login&username=" & User & "&password=" & Pwd
& "&submit=login"
Dim CC As New CookieContainer
Dim myWriter As StreamWriter
Dim sr As StreamReader
Request = WebRequest.Create(url)
Request.Timeout = 120 * 1000
Request.CookieContainer = CC
Request.Method = "POST"
Request.ContentLength = params.Length
Request.ContentType = "application/x-www-form-urlencoded"
Request.KeepAlive = True
myWriter = New StreamWriter(Request.GetRequestStream())
myWriter.Write(params)
myWriter.Close()
Response = Request.GetResponse()
Response.Cookies = Request.CookieContainer.GetCookies(Request.Request Uri)
For i = 0 To Response.Cookies.Count - 1
CC.Add(Response.Cookies(i))
Next
sr = New StreamReader(Response.GetResponseStream(), Encoding.GetEncoding(850))
ResultHTML = sr.ReadToEnd()
-----------------------------------------------------------------------------
Then i could create a new request and navigate to the page with my file..
Thanks for your help
"MARTIN LANNY" wrote: I have the exact same problem. I need to download the csv file from Google AdSense. Google requires the name and password to be send using "POST" method.
This code (below) will only download the html content of the page, but if url points to file it doesn't do anything. Can someone amend this code to work for files as well?
Public Function GetPageHTML(ByVal URL As String) As String Dim myWebClient As New WebClient Dim myNameValueCollection As New NameValueCollection myNameValueCollection.Add("username", "joedoe") myNameValueCollection.Add("password", "123456") Dim responseArray As Byte() = myWebClient.UploadValues(URL, "POST", myNameValueCollection) GetPageHTML = Encoding.UTF8.GetString(responseArray) End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James |
last post by:
Hello group:
I guessing there is no way to create an OLEDB linked table in Access
to SQL Server, am I correct? Basically, I've currently migrated one of
my Access database tables to SQL Server,...
|
by: google |
last post by:
My Crystal reports are being supplied the logon credentials via a C# code class that recursively loops through all the tables present in the reports and applies the login credentials (Servername,...
|
by: rfontaine |
last post by:
I have a virtual directory on IIS 5.0 to a remote share on a Windows 2003
file server. The "connect as" is a domain user account. The share as read
permission for everyone and the NTFS permission...
|
by: Milan Todorovic |
last post by:
Hello,
I need help. I have experience in ASP.NET programming, but this is my first
dealing with Crystal Reports. I'm trying to make the most basic report
purely for testing purposes: connect to...
|
by: J-T |
last post by:
Hi All,
We have an asp.net application on a windows 2003 server which is part of a
domain controller which my worksatis is too. We have impersonated in our
applciation with a fixed identity...
|
by: bonita |
last post by:
I come across the error
"CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed."
After I move my asp.net code from the development platform (XP
professional) to the production web...
|
by: Marty Cruise |
last post by:
I successfully deploy my application to 20 domain users. Only one new user
is giving me a problem, although he can access all domain resources.
When he clicks the installation link on the...
|
by: Manuel |
last post by:
Hi,
Using the PIA "Microsoft Outlook 11 Object Library".
I've noticed that the Logon method of the NameSpace Object is simply ignored.
My Outlook 2003 is full updated.
For example if I...
|
by: drummerpunk10 |
last post by:
Sorry if this is off topic, I haven't really used this forum a lot so I don't know where to put it. Anyways I have a game application that runs off a list games and users on a file, that I built in...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |