|
-
Oct 20th, 2011, 07:59 AM
#1
Thread Starter
Hyperactive Member
Issues with date time format while downloading the web page
I use following code to download a web page source code in my project:
vb Code:
Private Function dlwebFile(ByVal sUrl As String, ByVal sFile As String) As Boolean
Try
Dim wr As HttpWebRequest = WebRequest.Create(sUrl)
wr.Method = "POST"
'wr.ContentLength = strPostData.Length
wr.ContentType = "application/x-www-form-urlencoded"
wr.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)"
wr.CookieContainer = New CookieContainer
Dim sw As StreamWriter = New StreamWriter(wr.GetRequestStream)
'sw.Write(strPostData)
sw.Close()
Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
Using str As Stream = ws.GetResponseStream()
Dim inBuf(100000000) As Byte 'allows to download upto 100 mb file
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
Using fstr As FileStream = New FileStream(sFile, FileMode.Create)
fstr.Write(inBuf, 0, bytesRead)
End Using
End Using
Return True
Catch ex As Exception
Return False
End Try
End Function
The web page I am trying to download is a intranet site. I am periodically downloading the web page for archiving purpose for future reference. The web page will list the current active jobs/projects we work. We process 100's of jobs everyday. The list item will have the Project id, Project name, Project deadline, etc.
The download works fine. the web page is downloaded locally. The problem is the date/time format is changed to some other format. If I view the web page in browser, the deadline of one of the project shows as "7/15 03:00".
However, the downloaded webpage shows the deadline of that project as "Wed Jul 14 16:30:00 CDT 2010". I believe it shows in CDT timezone. Also, it shows couple of other timezone too. I think the project might be created from those countries. I am in India timezone.
Can someone help me on solving this issue?
Thanks
-
Oct 20th, 2011, 11:50 AM
#2
Re: Issues with date time format while downloading the web page
Maybe this will help you out.
-
Oct 20th, 2011, 08:01 PM
#3
Thread Starter
Hyperactive Member
Re: Issues with date time format while downloading the web page
Thanks. I know how to convert from one timezone to another. I would like to stop changing the date time format conversion in first place. It is not simple to find and replace the date time format changes in html source code. The date time format is changed in tons of places.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|