Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
get a webpage with vbs
Logged in as: Guest
arrSession:exec spGetSession 2,16,31211
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Post a VBScript
>> get a webpage with vbs
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
get a webpage with vbs -
2/17/2006 3:00:23 AM
kirrilian
Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status:
offline
get an authenticated webpage with vbs
getURL"un", "pw","http://yoursite.com/path/to/file.txt"
Sub getFTP(un,pw,url)
WScript.Echo url
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
WScript.Echo "********** start **************"
Call objHTTP.Open("GET", url, False,un,pw)
objHTTP.Send
WScript.Echo(objHTTP.ResponseText)
WScript.Echo "********** End **************"
'objHTTP = Nothing
End Sub
thanks to skione for the tip on the authenticated part
_____________________________
Have you searched
here
?
VBScript Fundamentals
My Site
Post #: 1
RE: get a webpage with vbs -
10/12/2006 8:46:20 PM
est
Posts: 39
Score: 0
Joined: 10/12/2006
Status:
offline
Thanks for the code. And i bet there is a coding bug in your script. Try this 'famous' iGet.vbs
Set xPost = CreateObject("Microsoft.XMLHTTP") xPost.Open "GET",LCase(WScript.Arguments(0)),0 xPost.Send() Set sGet = CreateObject("ADODB.Stream") sGet.Mode = 3 sGet.Type = 1 sGet.Open() sGet.Write(xPost.responseBody) sGet.SaveToFile LCase(WScript.Arguments(1)),2
Usage: cscript iGet.vbs url file
_____________________________
Do NOT program in a programmer's way
(in reply to
kirrilian
)
Post #: 2
RE: get a webpage with vbs -
10/19/2006 8:58:39 AM
Fredledingue
Posts: 337
Score: 0
Joined: 5/9/2005
From:
Status:
offline
Purpose: get Y!News without garbage
<SCRIPT LANGUAGE="VBScript"> <!-- sub window_onLoad() '----------------------------------------------------------- Title = "Pure YahooReuter HomePage" '---------process the file line by line------------- NewHtm = "<!--version modified by Fredledingue's html cleaner -->" & VbCrlf & "<HTML><HEAD><TITLE>My home page</TITLE>" & VbCrlf LineCount = 0 DelLineCount = 0 DelImgCount = 0 IsScript = False IsGarbage = False Shrink = False '--------download source--------- With CreateObject("MSXML2.XMLHTTP") .open "GET", "http://news.yahoo.com/news?tmpl=index&cid=586&/", False .send t =.responseText End With '--------prepare source text------ t = t & ">" t = Replace(t,Chr(10), " ") t = Replace(t,Chr(11), " ") t = Replace(t,Chr(12), " ") t = Replace(t,Chr(13), " ") t = Replace(t,Chr(14), " ") t = Replace(t,Chr(15), " ") t = Replace(t,VbCrlf, "") t = Replace(t,"href=""/","href=""http://news.yahoo.com/") t = Replace(t," class=", "><class=") t = Replace(t,"<h2>", "") t = Replace(t,"</h2>", "") t = Replace(t,">", ">" & VbCrlf) t = Replace(t,"Copyright ©", "<FONT size=1>Copyright ©") t = Replace(t,"More in Yahoo!", "<hr noshade size=""1"">More in Yahoo!") t = Replace(t,"taken in reliance thereon.", "taken in reliance thereon.</FONT>") t = VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & t & VbCrlf & "EndOfOriginalY" & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf & VbCrlf '--------scan source text line by line------ L = Split(t, vbCrlf, -1, 1) i = 0 Do Until L(i) = "EndOfOriginalY" '--------count lines------ LineCount = LineCount +1 '---------remove unwanted code------- If InStr(L(i),"class=")>0 Or InStr(L(i),"<NOSCRIPT")>0 Or InStr(L(i),"<noscript")>0 Or InStr(L(i),"</NOSCRIPT")>0 Or InStr(L(i),"</noscript")>0 Then DelLineCount = DelLineCount +1 Else 'If InStr(L(i+1),"us.a1.yimg.com")>0 Then 'DelLineCount = DelLineCount +2 'i=i+1 'Else 'If InStr(L(i+2),"ADVERTISEMENT")>0 Then 'DelLineCount = DelLineCount +4 'i=i+8 'Else '-------remove garbage----- If IsGarbage = True Then DelLineCount = DelLineCount +1 If InStr(L(i-2),"<a href=""0'>http://us.rd.yahoo.com")>0 Or _ InStr(L(i-1),"Include Photos")>0 Or _ InStr(L(i-10),"More News Feeds")>0 Or _ InStr(L(i+1),"</head>")>0 Or _ InStr(L(i+4),"More in Yahoo!")>0 Then IsGarbage = False 'msgbox L(i+1) & vbcrlf & IsGarbage,,"debug 1" End If Else If InStr(L(i),"<body onload=")>0 Or _ InStr(L(i+3),"<div id=""switcheroo")>0 Or _ InStr(L(i),"<h6>")>0 Or _ InStr(L(i),"<META HTTP-EQUIV=")>0 Or _ InStr(L(i),"id=""sidebar")>0 Then DelLineCount = DelLineCount +1 IsGarbage = True 'msgbox L(i) & vbcrlf & IsGarbage,,"debug 2" Else '-------remove script----- If IsScript = True Then DelLineCount = DelLineCount +1 If InStr(L(i),"</script")>0 Or InStr(L(i),"</SCRIPT")>0 Then IsScript = False End If Else If InStr(L(i),"<script")>0 Or InStr(L(i),"<SCRIPT")>0 Then DelLineCount = DelLineCount +1 If InStr(L(i),"</script")=0 And InStr(L(i),"</SCRIPT")=0 Then IsScript = True End If Else If InStr(L(i),"href='javascript")>0 Then DelLineCount = DelLineCount +1 Else '------------shrink end of page--------- If Shrink = True Then If InStr(L(i),"<li")>0 Or _ InStr(L(i),"</li")>0 Or _ InStr(L(i),"<div")>0 Or _ InStr(L(i),"</div")>0 Or _ InStr(L(i),"<!--")>0 Then DelLineCount = DelLineCount +1 Else NewHtm = NewHtm & VbCrlf & Replace(L(i), "</a>", "</a> ") '-----espace entre les hyperliens End If Else If InStr(L(i),"More in Yahoo!")>0 Then NewHtm = NewHtm & VbCrlf & L(i) Shrink = True Else '---------open links in new windows-------- If InStr(1,L(i),"href=""",1)>0 Then NewHtm = NewHtm & Replace(L(i),">","target=""_blank"">") Else '---------remove notes------------ If InStr(L(i),"<!--")>0 Then DelLineCount = DelLineCount +1 '------accpet line------------ Else NewHtm = NewHtm & VbCrlf & L(i) End If End If End If End If End If End If End If End If 'End If End If End If i = i +1 Loop NewHtm = Left(NewHtm, Len(NewHtm)-1)& VbCrlf & "</BODY></HTML>" '-------------------------------- 'MsgBox "Lignes effacées: " & DelLineCount & "/" & LineCount,, Title '---------End of Script----------------- Document.Body.InnerHTML = NewHtm end sub --> </SCRIPT>
save that to pureyahoonews.html
_____________________________
Fred
(in reply to
est
)
Post #: 3
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
Post a VBScript
>> get a webpage with vbs
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI