.js eller .vbs som läser svaret ur en php-fil?

Permalänk
Medlem

.js eller .vbs som läser svaret ur en php-fil?

Har ett script i php som ger en output. Men för att använda den i samurize så måste jag ha ett script som läser ut svaret. Hur gör jag det?

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

'GetHTML.vbs Option Explicit Dim iArgCnt iArgCnt = WScript.Arguments.Count if iArgCnt <> 1 then Call Usage() Call Main() Sub Main() Dim strURL strURL = WScript.Arguments.Item(0) With CreateObject("InternetExplorer.Application") .Navigate strURL Do Until .ReadyState = 4 Wscript.sleep 10 Loop ' Document innerHTML skrivs ut i Meddelande boxen MsgBox .document.body.innerHTML .Quit End With End Sub Sub Usage() Wscript.Echo "usage: GetHTML.vbs [A valid URL goes here]" wscript.Quit End Sub

Detta borde fungera för att få innehållet... Eller åtminstonne lite modifierat. Samma sak går att åstadkomma med JS, använd bara XMLHTTP ïstället för att fånga koden.

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

Ok, tack!
Var ska jag ändra urlet då? strURL?

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

Det är kodat så du skickar in URL:en som en parameter, alltså om du triggar från DOS prompt:

C:\> GetHTML.vbs http://www.google.com

**************
Annars kan du byta raden:

strURL = WScript.Arguments.Item(0)

Mot, t.ex.:

strURL = "http://www.google.com"

**************

/Anders

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

Tyvärr, jag får det inte att fungera.
1. Det finns ingen funktion att köra
2. Det enda som händer är att en ruta kommer upp och kör echo usage: GetHTML.vbs [A valid URL goes here]

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

'GetHTML2.vbs Option Explicit Dim strReturnValueFromFunction strReturnValueFromFunction = strGetDataFromURL() MsgBox strReturnValueFromFunction '****** Function to get data from an URL ************ Function strGetDataFromURL() Dim strURL strURL = "http://www.google.com" With CreateObject("InternetExplorer.Application") .Navigate strURL Do Until .ReadyState = 4 Wscript.sleep 10 Loop strGetDataFromURL = .document.body.innerHTML .Quit End With End Function '****** End Function to get data from an URL ************

EDIT:
OK, nu kommer "strReturnValueFromFunction" variabeln att innehålla HTML data från Google.com istället...

/Anders

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

Hur gör jag om det till en funktion och så att jag kan köra den i Samurize..
Function test() hjälpte inte

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

Se editerat svar ovan...

/Anders

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

Tack, men Samurize klagar på odefinierad variabel Wscript?

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

Hmm... Kör du det som ASP eller VBScript i en HTML sida?

Detta är alltså kodat för Wscript för Windows och har egentligen ingen koppling till HTML... Dock är koden för "vanlig" VBScript i en HTML sida syntax mässigt likadan, men med avsaknad av vissa functioner, som då t.ex. Wscript.

Om det rör sig om en HTML sida skulle jag hellre koda det i JavaScript och använda XMLHTTP för anropet...

Vet inget om Samurize...

/Anders

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

Fan också :/
Aja, får söka hjälp annat håll.
Någon som kan javascript?

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

Jag sa aldrig att jag inte kunde JS...

<html> <head> <title>Get external HTML</title> <script language="JavaScript"> function getExternalUrlContent(url) { if(document.all) { // IE version var xmlDoc = new ActiveXObject("Microsoft.XMLHTTP"); xmlDoc.Open("GET", url, false); xmlDoc.Send(); } else { // Mozilla/Netscrap 6+ version var xmlDoc = new XMLHttpRequest(); xmlDoc.open("GET", url, false); xmlDoc.send(null); } try { alert(xmlDoc.responseText); } catch(e) { alert("Error occurred:\n\n" + e.number + " " + e.description); } } </script> </head> <body onload="getExternalUrlContent('test2.htm');"> External content will pop-up... </body> </html>

Det enda jag kan tänka mig du stöter på problem med är om du försöker accessa något utanför din egenom domän... men testa på...

'test2.htm' är alltså sidan den nu läser in...

/Anders

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

function sailor() { return getExternalUrlContent("http://localhost/sailor.php"); } function getExternalUrlContent(url) { var xmlDoc = new ActiveXObject("Microsoft.XMLHTTP"); xmlDoc.Open("GET", url, false); xmlDoc.Send(); try { alert(xmlDoc.responseText); } catch(e) { alert("Error occurred:\n\n" + e.number + " " + e.description); } }

Har jag nu, men den säger att ett objekt förväntas?

Såhär ser ett avancerat tv-skript till Samurize ut. Du kunde kanske skumma igenom snabbt?

/*****************************************************************************************\ | This GetTVscript is written by kael | \*****************************************************************************************/ var showTime = true ;// Option to show the time in the output (true or false) var timeDelimiter = ":" ;// Option what to separate hours and minutes with(":" "." or what you want) var timeProgramSeparator = " " ;// Option what to separate time and program with var noProgramYet = "Inget program" ;// The text showing when there are no program yet var noProgramNow = "Sändningsuppehåll" ;// The text showing when there are no program right now var noProgramEnd = "Sändningsslut" ;// The text showing when there are no program any more //To use multiple lines in output, edit this function for your pleasure ("\r\n" is a new line) /* // and remove this line function GetMyTV() { return "SVT1: "+GetSVT1()+"\r\n"+"SVT2: "+GetSVT2()+"\r\n"+"TV3: "+GetTV3()+"\r\n"+"TV4: "+GetTV4(); } */ // and this one function GetSVT1() { return GetTV_(21, 0); } function GetBarSVT1() { return GetBar_(21); } function GetNextSVT1() { return GetTV_(21, 1); } function GetSVT2() { return GetTV_(22, 0); } function GetBarSVT2() { return GetBar_(22); } function GetNextSVT2() { return GetTV_(22, 1); } function GetTV3() { return GetTV_(26, 0); } function GetBarTV3() { return GetBar_(26); } function GetNextTV3() { return GetTV_(26, 1); } function GetTV4() { return GetTV_(27, 0); } function GetBarTV4() { return GetBar_(27); } function GetNextTV4() { return GetTV_(27, 1); } function GetKanal5() { return GetTV_(10, 0); } function GetBarKanal5() { return GetBar_(10); } function GetNextKanal5() { return GetTV_(10, 1); } function GetViasatActionNature() { return GetTV_(28, 0); } function GetBarViasatActionNature() { return GetBar_(28); } function GetNextViasatActionNature() { return GetTV_(28, 1); } function GetZTV() { return GetTV_(42, 0); } function GetBarZTV() { return GetBar_(42); } function GetNextZTV() { return GetTV_(42, 1); } function GetTV8() { return GetTV_(43, 0); } function GetBarTV8() { return GetBar_(43); } function GetNextTV8() { return GetTV_(43, 1); } function GetTV1000() { return GetTV_(33, 0); } function GetBarTV1000() { return GetBar_(33); } function GetNextTV1000() { return GetTV_(33, 1); } function GetCinema() { return GetTV_(34, 0); } function GetBarCinema() { return GetBar_(34); } function GetNextCinema() { return GetTV_(34, 1); } function GetCanalPlus() { return GetTV_(11, 0); } function GetBarCanalPlus() { return GetBar_(11); } function GetNextCanalPlus() { return GetTV_(11, 1); } function GetCanalPlusGul() { return GetTV_(12, 0); } function GetBarCanalPlusGul() { return GetBar_(12); } function GetNextCanalPlusGul() { return GetTV_(12, 1); } function GetCanalPlusBla() { return GetTV_(55, 0); } function GetBarCanalPlusBla() { return GetBar_(55); } function GetNextCanalPlusBla() { return GetTV_(55, 1); } function GetCanalPlusZap() { return GetTV_(140, 0); } function GetBarCanalPlusZap() { return GetBar_(140); } function GetNextCanalPlusZap() { return GetTV_(140, 1); } function GetMTV() { return GetTV_(14, 0); } function GetBarMTV() { return GetBar_(14); } function GetNextMTV() { return GetTV_(14, 1); } function GetMTV2() { return GetTV_(74, 0); } function GetBarMTV2() { return GetBar_(74); } function GetNextMTV2() { return GetTV_(74, 1); } function GetEurosport() { return GetTV_(9, 0); } function GetBarEurosport() { return GetBar_(9); } function GetNextEurosport() { return GetTV_(9, 1); } function GetViaSatSport() { return GetTV_(53, 0); } function GetBarViaSatSport() { return GetBar_(53); } function GetNextViaSatSport() { return GetTV_(53, 1); } function GetExtremesports() { return GetTV_(67, 0); } function GetBarExtremesports() { return GetBar_(67); } function GetNextExtremesports() { return GetTV_(67, 1); } function GetManchesterUnitedTV() { return GetTV_(193, 0); } function GetBarManchesterUnitedTV() { return GetBar_(193); } function GetNextManchesterUnitedTV() { return GetTV_(193, 1); } function GetCNN() { return GetTV_(5, 0); } function GetBarCNN() { return GetBar_(5); } function GetNextCNN() { return GetTV_(5, 1); } function GetEurosportNews() { return GetTV_(141, 0); } function GetBarEurosportNews() { return GetBar_(141); } function GetNextEurosportNews() { return GetTV_(141, 1); } function GetSkyNews() { return GetTV_(18, 0); } function GetBarSkyNews() { return GetBar_(18); } function GetNextSkyNews() { return GetTV_(18, 1); } function GetCNBC() { return GetTV_(56, 0); } function GetBarCNBC() { return GetBar_(56); } function GetNextCNBC() { return GetTV_(56, 1); } function GetNBCEurope() { return GetTV_(93, 0); } function GetBarNBCEurope() { return GetBar_(93); } function GetNextNBCEurope() { return GetTV_(93, 1); } function Get24() { return GetTV_(101, 0); } function GetBar24() { return GetBar_(101); } function GetNext24() { return GetTV_(101, 1); } function GetSVTEuropa() { return GetTV_(100, 0); } function GetBarSVTEuropa() { return GetBar_(100); } function GetNextSVTEuropa() { return GetTV_(100, 1); } function GetTV4Plus() { return GetTV_(142, 0); } function GetBarTV4Plus() { return GetBar_(142); } function GetNextTV4Plus() { return GetTV_(142, 1); } function GetBarnkanalen() { return GetTV_(143, 0); } function GetBarBarnkanalen() { return GetBar_(143); } function GetNextBarnkanalen() { return GetTV_(143, 1); } function GetORTInt() { return GetTV_(139, 0); } function GetBarORTInt() { return GetBar_(139); } function GetNextORTInt() { return GetTV_(139, 1); } function GetDiscoveryChannel() { return GetTV_(7, 0); } function GetBarDiscoveryChannel() { return GetBar_(7); } function GetNextDiscoveryChannel() { return GetTV_(7, 1); } function GetDiscoveryCivilisation() { return GetTV_(118, 0); } function GetBarDiscoveryCivilisation() { return GetBar_(118); } function GetNextDiscoveryCivilisation() { return GetTV_(118, 1); } function GetDiscoveryScience() { return GetTV_(119, 0); } function GetBarDiscoveryScience() { return GetBar_(119); } function GetNextDiscoveryScience() { return GetTV_(119, 1); } function GetDiscoveryTAndA() { return GetTV_(120, 0); } function GetBarDiscoveryTAndA() { return GetBar_(120); } function GetNextDiscoveryTAndA() { return GetTV_(120, 1); } function GetDiscoveryMix() { return GetTV_(89, 0); } function GetBarDiscoveryMix() { return GetBar_(89); } function GetNextDiscoveryMix() { return GetTV_(89, 1); } function GetAnimalPlanet() { return GetTV_(54, 0); } function GetBarAnimalPlanet() { return GetBar_(54); } function GetNextAnimalPlanet() { return GetTV_(54, 1); } function GetViaSatExplorer() { return GetTV_(76, 0); } function GetBarViaSatExplorer() { return GetBar_(76); } function GetNextViaSatExplorer() { return GetTV_(76, 1); } function GetTravel() { return GetTV_(25, 0); } function GetBarTravel() { return GetBar_(25); } function GetNextTravel() { return GetTV_(25, 1); } function GetAvante() { return GetTV_(68, 0); } function GetBarAvante() { return GetBar_(68); } function GetNextAvante() { return GetTV_(68, 1); } function GetNationalGeographic() { return GetTV_(48, 0); } function GetBarNationalGeographic() { return GetBar_(48); } function GetNextNationalGeographic() { return GetTV_(48, 1); } function GetCartoonNetwork() { return GetTV_(4, 0); } function GetBarCartoonNetwork() { return GetBar_(4); } function GetNextCartoonNetwork() { return GetTV_(4, 1); } function GetFoxKids() { return GetTV_(60, 0); } function GetBarFoxKids() { return GetBar_(60); } function GetNextFoxKids() { return GetTV_(60, 1); } function GetNickelodeon() { return GetTV_(45, 0); } function GetBarNickelodeon() { return GetBar_(45); } function GetNextNickelodeon() { return GetTV_(45, 1); } function GetDisneyChannel() { return GetTV_(147, 0); } function GetBarDisneyChannel() { return GetBar_(147); } function GetNextDisneyChannel() { return GetTV_(147, 1); } function GetTCM() { return GetTV_(24, 0); } function GetBarTCM() { return GetBar_(24); } function GetNextTCM() { return GetTV_(24, 1); } function GetTheStudio() { return GetTV_(70, 0); } function GetBarTheStudio() { return GetBar_(70); } function GetNextTheStudio() { return GetTV_(70, 1); } function GetHallmark() { return GetTV_(13, 0); } function GetBarHallmark() { return GetBar_(13); } function GetNextHallmark() { return GetTV_(13, 1); } function GetVH1() { return GetTV_(47, 0); } function GetBarVH1() { return GetBar_(47); } function GetNextVH1() { return GetTV_(47, 1); } function GetE() { return GetTV_(114, 0); } function GetBarE() { return GetBar_(114); } function GetNextE() { return GetTV_(114, 1); } function GetStyle() { return GetTV_(49, 0); } function GetBarStyle() { return GetBar_(49); } function GetNextStyle() { return GetTV_(49, 1); } function GetFashionTV() { return GetTV_(82, 0); } function GetBarFashionTV() { return GetBar_(82); } function GetNextFashionTV() { return GetTV_(82, 1); } function GetClub() { return GetTV_(115, 0); } function GetBarClub() { return GetBar_(115); } function GetNextClub() { return GetTV_(115, 1); } function GetRealityTV() { return GetTV_(117, 0); } function GetBarRealityTV() { return GetBar_(117); } function GetNextRealityTV() { return GetTV_(117, 1); } function GetGodChannel() { return GetTV_(111, 0); } function GetBarGodChannel() { return GetBar_(111); } function GetNextGodChannel() { return GetTV_(111, 1); } function GetEuronews() { return GetTV_(104, 0); } function GetBarEuronews() { return GetBar_(104); } function GetNextEuronews() { return GetTV_(104, 1); } function GetHRT1() { return GetTV_(50, 0); } function GetBarHRT1() { return GetBar_(50); } function GetNextHRT1() { return GetTV_(50, 1); } function GetPlayboy() { return GetTV_(110, 0); } function GetBarPlayboy() { return GetBar_(110); } function GetNextPlayboy() { return GetTV_(110, 1); } function GetPinkPlus() { return GetTV_(109, 0); } function GetBarPinkPlus() { return GetBar_(109); } function GetNextPinkPlus() { return GetTV_(109, 1); } function GetTVFinland() { return GetTV_(29, 0); } function GetBarTVFinland() { return GetBar_(29); } function GetNextTVFinland() { return GetTV_(29, 1); } function GetYLETV1() { return GetTV_(31, 0); } function GetBarYLETV1() { return GetBar_(31); } function GetNextYLETV1() { return GetTV_(31, 1); } function GetYLETV2() { return GetTV_(36, 0); } function GetBarYLETV2() { return GetBar_(36); } function GetNextYLETV2() { return GetTV_(36, 1); } function GetTV3Finland() { return GetTV_(39, 0); } function GetBarTV3Finland() { return GetBar_(39); } function GetNextTV3Finland() { return GetTV_(39, 1); } function GetNelonen() { return GetTV_(189, 0); } function GetBarNelonen() { return GetBar_(189); } function GetNextNelonen() { return GetTV_(189, 1); } function GetTVNorge() { return GetTV_(73, 0); } function GetBarTVNorge() { return GetBar_(73); } function GetNextTVNorge() { return GetTV_(73, 1); } function GetNRK1() { return GetTV_(72, 0); } function GetBarNRK1() { return GetBar_(72); } function GetNextNRK1() { return GetTV_(72, 1); } function GetNRK2() { return GetTV_(63, 0); } function GetBarNRK2() { return GetBar_(63); } function GetNextNRK2() { return GetTV_(63, 1); } function GetTV2Norge() { return GetTV_(37, 0); } function GetBarTV2Norge() { return GetBar_(37); } function GetNextTV2Norge() { return GetTV_(37, 1); } function GetTV3Norge() { return GetTV_(62, 0); } function GetBarTV3Norge() { return GetBar_(62); } function GetNextTV3Norge() { return GetTV_(62, 1); } function GetZTVNorge() { return GetTV_(75, 0); } function GetBarZTVNorge() { return GetBar_(75); } function GetNextZTVNorge() { return GetTV_(75, 1); } function GetTVDanmark1() { return GetTV_(103, 0); } function GetBarTVDanmark1() { return GetBar_(103); } function GetNextTVDanmark1() { return GetTV_(103, 1); } function GetTVDanmark2() { return GetTV_(105, 0); } function GetBarTVDanmark2() { return GetBar_(105); } function GetNextTVDanmark2() { return GetTV_(105, 1); } function GetDR1() { return GetTV_(58, 0); } function GetBarDR1() { return GetBar_(58); } function GetNextDR1() { return GetTV_(58, 1); } function GetDR2() { return GetTV_(59, 0); } function GetBarDR2() { return GetBar_(59); } function GetNextDR2() { return GetTV_(59, 1); } function GetTV2Danmark() { return GetTV_(71, 0); } function GetBarTV2Danmark() { return GetBar_(71); } function GetNextTV2Danmark() { return GetTV_(71, 1); } function GetTV2Zulu() { return GetTV_(126, 0); } function GetBarTV2Zulu() { return GetBar_(126); } function GetNextTV2Zulu() { return GetTV_(126, 1); } function GetTV3Danmark() { return GetTV_(57, 0); } function GetBarTV3Danmark() { return GetBar_(57); } function GetNextTV3Danmark() { return GetTV_(57, 1); } function Get3PlusDanmark() { return GetTV_(83, 0); } function GetBar3PlusDanmark() { return GetBar_(83); } function GetNext3PlusDanmark() { return GetTV_(83, 1); } function GetBBCFood() { return GetTV_(149, 0); } function GetBarBBCFood() { return GetBar_(149); } function GetNextBBCFood() { return GetTV_(149, 1); } function GetBBCPrime() { return GetTV_(2, 0); } function GetBarBBCPrime() { return GetBar_(2); } function GetNextBBCPrime() { return GetTV_(2, 1); } function GetBBCWorld() { return GetTV_(3, 0); } function GetBarBBCWorld() { return GetBar_(3); } function GetNextBBCWorld() { return GetTV_(3, 1); } function GetMBC() { return GetTV_(88, 0); } function GetBarMBC() { return GetBar_(88); } function GetNextMBC() { return GetTV_(88, 1); } function GetMDR() { return GetTV_(91, 0); } function GetBarMDR() { return GetBar_(91); } function GetNextMDR() { return GetTV_(91, 1); } function GetNDR() { return GetTV_(92, 0); } function GetBarNDR() { return GetBar_(92); } function GetNextNDR() { return GetTV_(92, 1); } function GetArte() { return GetTV_(84, 0); } function GetBarArte() { return GetBar_(84); } function GetNextArte() { return GetTV_(84, 1); } function GetPRO7() { return GetTV_(98, 0); } function GetBarPRO7() { return GetBar_(98); } function GetNextPRO7() { return GetTV_(98, 1); } function GetSudwest() { return GetTV_(99, 0); } function GetBarSudwest() { return GetBar_(99); } function GetNextSudwest() { return GetTV_(99, 1); } function GetBayerischesFernsehen() { return GetTV_(81, 0); } function GetBarBayerischesFernsehen() { return GetBar_(81); } function GetNextBayerischesFernsehen() { return GetTV_(81, 1); } function GetRBBBrandenburg() { return GetTV_(94, 0); } function GetBarRBBBrandenburg() { return GetBar_(94); } function GetNextRBBBrandenburg() { return GetTV_(94, 1); } function GetRTL() { return GetTV_(16, 0); } function GetBarRTL() { return GetBar_(16); } function GetNextRTL() { return GetTV_(16, 1); } function GetRTL2() { return GetTV_(15, 0); } function GetBarRTL2() { return GetBar_(15); } function GetNextRTL2() { return GetTV_(15, 1); } function GetViva() { return GetTV_(106, 0); } function GetBarViva() { return GetBar_(106); } function GetNextViva() { return GetTV_(106, 1); } function GetVivaPlus() { return GetTV_(85, 0); } function GetBarVivaPlus() { return GetBar_(85); } function GetNextVivaPlus() { return GetTV_(85, 1); } function GetVox() { return GetTV_(107, 0); } function GetBarVox() { return GetBar_(107); } function GetNextVox() { return GetTV_(107, 1); } function GetZDF() { return GetTV_(51, 0); } function GetBarZDF() { return GetBar_(51); } function GetNextZDF() { return GetTV_(51, 1); } function GetWDR() { return GetTV_(108, 0); } function GetBarWDR() { return GetBar_(108); } function GetNextWDR() { return GetTV_(108, 1); } function GetSAT1() { return GetTV_(17, 0); } function GetBarSAT1() { return GetBar_(17); } function GetNextSAT1() { return GetTV_(17, 1); } function Get3SAT() { return GetTV_(1, 0); } function GetBar3SAT() { return GetBar_(1); } function GetNext3SAT() { return GetTV_(1, 1); } function GetARD() { return GetTV_(69, 0); } function GetBarARD() { return GetBar_(69); } function GetNextARD() { return GetTV_(69, 1); } function GetDeutscheWelle() { return GetTV_(6, 0); } function GetBarDeutscheWelle() { return GetBar_(6); } function GetNextDeutscheWelle() { return GetTV_(6, 1); } function GetDSF() { return GetTV_(8, 0); } function GetBarDSF() { return GetBar_(8); } function GetNextDSF() { return GetTV_(8, 1); } function GetKabel1() { return GetTV_(113, 0); } function GetBarKabel1() { return GetBar_(113); } function GetNextKabel1() { return GetTV_(113, 1); } function GetTV5() { return GetTV_(40, 0); } function GetBarTV5() { return GetBar_(40); } function GetNextTV5() { return GetTV_(40, 1); } function GetTVChile() { return GetTV_(52, 0); } function GetBarTVChile() { return GetBar_(52); } function GetNextTVChile() { return GetTV_(52, 1); } function GetTVPolonia() { return GetTV_(66, 0); } function GetBarTVPolonia() { return GetBar_(66); } function GetNextTVPolonia() { return GetTV_(66, 1); } function GetMezzo() { return GetTV_(46, 0); } function GetBarMezzo() { return GetBar_(46); } function GetNextMezzo() { return GetTV_(46, 1); } function GetFrance5() { return GetTV_(86, 0); } function GetBarFrance5() { return GetBar_(86); } function GetNextFrance5() { return GetTV_(86, 1); } function GetRaiUno() { return GetTV_(64, 0); } function GetBarRaiUno() { return GetBar_(64); } function GetNextRaiUno() { return GetTV_(64, 1); } function GetRaiDue() { return GetTV_(65, 0); } function GetBarRaiDue() { return GetBar_(65); } function GetNextRaiDue() { return GetTV_(65, 1); } function GetTVE() { return GetTV_(41, 0); } function GetBarTVE() { return GetBar_(41); } function GetNextTVE() { return GetTV_(41, 1); } function GetRTPInt() { return GetTV_(192, 0); } function GetBarRTPInt() { return GetBar_(192); } function GetNextRTPInt() { return GetTV_(192, 1); } function GetDTU7() { return GetTV_(80, 0); } function GetBarDTU7() { return GetBar_(80); } function GetNextDTU7() { return GetTV_(80, 1); } function GetTheAdultChannel() { return GetTV_(87, 0); } function GetBarTheAdultChannel() { return GetBar_(87); } function GetNextTheAdultChannel() { return GetTV_(87, 1); } function GetTV_(channel, count) { var txt = GetPage_(channel); if(txt.substr(0,5)=="Error") return txt; try { var now = -1; var lines = txt.split("\r\n"); for(var i=lines.length-2;i>=0;i--) { var time = lines[i].substring(0,5); _time = new Date(); if((parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2)))<6) _time.setHours(parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2))+18,parseInt(time.substring(3,4))*10 + parseInt(time.substring(4,5)),0,0); else _time.setHours(parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2))-6,parseInt(time.substring(3,4))*10 + parseInt(time.substring(4,5)),0,0); _now = new Date(); if(_now.getHours()<6) _now.setHours(_now.getHours()+18); else _now.setHours(_now.getHours()-6); if(_time<_now) { now = i; break; } } if((now+count>=0) && (now+count<=lines.length-2)) return lines[now+count]; else return noProgramYet; } catch(e) { return "Error parsing file"; } } function GetBar_(channel) { var txt = GetPage_(channel); if(txt.substr(0,5)=="Error") return txt; try { var now = -1; var lines = txt.split("\r\n"); for(var i=lines.length-2;i>=0;i--) { var time = lines[i].substring(0,5); _time = new Date(); if((parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2)))<6) _time.setHours(parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2))+18,parseInt(time.substring(3,4))*10 + parseInt(time.substring(4,5)),0,0); else _time.setHours(parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2))-6,parseInt(time.substring(3,4))*10 + parseInt(time.substring(4,5)),0,0); _now = new Date(); if(_now.getHours()<6) _now.setHours(_now.getHours()+18); else _now.setHours(_now.getHours()-6); if(_time<_now) { now = i; break; } } if(now<0 || now>=(lines.length-2)) return 0; var time1 = lines[now].substring(0,5); var time1h = time1.substring(0,2); var time1m = time1.substring(3,5); var time2 = lines[now+1].substring(0,5); var time2h = time2.substring(0,2); var time2m = time2.substring(3,5); if(time1h<6) time1h=time1h*1+18; else time1h-=6; if(time2h<6) time2h=time2h*1+18; else time2h-=6; var totalmins = (time2h-time1h)*60+(time2m-time1m); var runningminutes = (_now.getHours()-time1h)*60+(_now.getMinutes()-time1m) return runningminutes/totalmins*100; } catch(e) { return "Error parsing file"; } } function GetPage_(channel) { try { var fs = new ActiveXObject("Scripting.FileSystemObject"); try { var file=fs.GetSpecialFolder(2)+"\\"+channel+".tv"; if(fs.FileExists(file)) { var f=fs.GetFile(file); var filetime = new Date(f.DateLastModified); var now = new Date(); var timeToDownload = new Date(); timeToDownload.setHours(6,15,0); if(timeToDownload>now || filetime>timeToDownload) { var filen = f.OpenAsTextStream(1); var txt = filen.ReadAll(); filen.Close(); return txt; } } } catch(e) { return "Error reading from file"; } finally { delete filetime; delete now; delete timeToDownload; } try { var http = new ActiveXObject("Microsoft.XMLHTTP"); http.Open("GET","http://www.dagenstv.com/se/chart/?cha="+channel+"&"+Math.random(),false); http.send(); var html = fixHTMLcodes_(http.responseText); } catch(e) { return "Error downloading page"; } finally { delete http; } try { var start = "\r\n <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"; var stop = "</table>"; html = html.substr(html.indexOf(start)+start.length+50); html = html.substr(0,html.indexOf(stop)); var txt=""; var lines = html.split("\r\n <tr>"); var endtime=""; for(var i=0;i<lines.length;i++) { var time = lines[i].substr(lines[i].indexOf(">")+1,5); var program = lines[i].substr(lines[i].indexOf("charteventname")+30); program = program.substr(0,program.indexOf("<")); if(program.indexOf("\r\n")!=-1) program = program.substr(0,program.indexOf("\r\n")); if(endtime!="") { var _endtime = new Date(); _endtime.setHours(parseInt(endtime.substring(0,1))*10 + parseInt(endtime.substring(1,2)),parseInt(endtime.substring(3,4))*10 + parseInt(endtime.substring(4,5)),0,0); var _time = new Date(); _time.setHours(parseInt(time.substring(0,1))*10 + parseInt(time.substring(1,2)),parseInt(time.substring(3,4))*10 + parseInt(time.substring(4,5)),0,0); if(_endtime<_time) { if(showTime) txt+=endtime.substring(0,2)+timeDelimiter+endtime.substring(3,5)+timeProgramSeparator; txt+=noProgramNow+"\r\n"; } } endtime = lines[i].substr(lines[i].indexOf("</span> (")+9,5); if(endtime.substr(2,1)!=":") endtime = ""; if(showTime) txt+=time.substring(0,2)+timeDelimiter+time.substring(3,5)+timeProgramSeparator; txt+=program+"\r\n"; } if(endtime!="") { var _endtime = new Date(); _endtime.setHours(parseInt(endtime.substring(0,1))*10 + parseInt(endtime.substring(1,2)),parseInt(endtime.substring(3,4))*10 + parseInt(endtime.substring(4,5)),0,0); var _time = new Date(); _time.setHours(5,59,0); if(_endtime<_time) { if(showTime) txt+=endtime.substring(0,2)+timeDelimiter+endtime.substring(3,5)+timeProgramSeparator; txt+=noProgramEnd+"\r\n"; } } } catch(e) { return "Error parsing page"; } try { var file=fs.CreateTextFile(file,true); file.Write(txt); } catch(e) { return "Error writing to file"; } finally { file.Close(); } } catch(e) { return "Error creating FileSystemObject"; } finally { delete fs; } return txt; } function fixHTMLcodes_(str) { str = str.replace(/å/g, "å"); str = str.replace(/ä/g, "ä"); str = str.replace(/ö/g, "ö"); str = str.replace(/Å/g, "Å"); str = str.replace(/Ä/g, "Ä"); str = str.replace(/Ö/g, "Ö"); str = str.replace(/&/g, "&"); str = str.replace(/"/g, "\""); str = str.replace(/&#130;/g, "?"); str = str.replace(/&#131;/g, "?"); str = str.replace(/&#132;/g, "?"); str = str.replace(/&#133;/g, "?"); str = str.replace(/&#134;/g, "?"); str = str.replace(/&#135;/g, "?"); str = str.replace(/&#136;/g, "?"); str = str.replace(/&#137;/g, "?"); str = str.replace(/&#138;/g, "?"); str = str.replace(/&#139;/g, "?"); str = str.replace(/&#140;/g, "?"); str = str.replace(/&#145;/g, "?"); str = str.replace(/&#146;/g, "?"); str = str.replace(/&#147;/g, "?"); str = str.replace(/&#148;/g, "?"); str = str.replace(/&#149;/g, "?"); str = str.replace(/&#150;/g, "?"); str = str.replace(/&#151;/g, "?"); str = str.replace(/&#152;/g, "?"); str = str.replace(/&#153;/g, "?"); str = str.replace(/&#154;/g, "?"); str = str.replace(/&#155;/g, "?"); str = str.replace(/&#156;/g, "?"); str = str.replace(/&#159;/g, "?"); str = str.replace(/ /g, " "); str = str.replace(/¡/g, "¡"); str = str.replace(/¢/g, "¢"); str = str.replace(/£/g, "£"); str = str.replace(/¤/g, "¤"); str = str.replace(/¥/g, "¥"); str = str.replace(/¦/g, "¦"); str = str.replace(/§/g, "§"); str = str.replace(/¨/g, "¨"); str = str.replace(/©/g, "©"); str = str.replace(/ª/g, "ª"); str = str.replace(/«/g, "«"); str = str.replace(/¬/g, "¬"); str = str.replace(/­/g, "_"); str = str.replace(/®/g, "®"); str = str.replace(/¯/g, "¯"); str = str.replace(/°/g, "°"); str = str.replace(/±/g, "±"); str = str.replace(/²/g, "²"); str = str.replace(/³/g, "³"); str = str.replace(/´/g, "´"); str = str.replace(/µ/g, "µ"); str = str.replace(/¶/g, "¶"); str = str.replace(/·/g, "·"); str = str.replace(/¸/g, "¸"); str = str.replace(/¹/g, "¹"); str = str.replace(/º/g, "º"); str = str.replace(/»/g, "»"); str = str.replace(/¼/g, "¼"); str = str.replace(/½/g, "½"); str = str.replace(/¾/g, "¾"); str = str.replace(/¿/g, "¿"); str = str.replace(/À/g, "À"); str = str.replace(/Á/g, "Á"); str = str.replace(/Â/g, "Â"); str = str.replace(/Ã/g, "Ã"); str = str.replace(/Ä/g, "Ä"); str = str.replace(/Å/g, "Å"); str = str.replace(/Æ/g, "Æ"); str = str.replace(/Ç/g, "Ç"); str = str.replace(/È/g, "È"); str = str.replace(/É/g, "É"); str = str.replace(/Ê/g, "Ê"); str = str.replace(/Ë/g, "Ë"); str = str.replace(/Ì/g, "Ì"); str = str.replace(/Í/g, "Í"); str = str.replace(/Î/g, "Î"); str = str.replace(/Ï/g, "Ï"); str = str.replace(/Ð/g, "Ð"); str = str.replace(/Ñ/g, "Ñ"); str = str.replace(/Ò/g, "Ò"); str = str.replace(/Ó/g, "Ó"); str = str.replace(/Ô/g, "Ô"); str = str.replace(/Õ/g, "Õ"); str = str.replace(/Ö/g, "Ö"); str = str.replace(/×/g, "×"); str = str.replace(/Ø/g, "Ø"); str = str.replace(/Ù/g, "Ù"); str = str.replace(/Ú/g, "Ú"); str = str.replace(/Û/g, "Û"); str = str.replace(/Ü/g, "Ü"); str = str.replace(/Ý/g, "Ý"); str = str.replace(/Þ/g, "Þ"); str = str.replace(/ß/g, "ß"); str = str.replace(/à/g, "à"); str = str.replace(/á/g, "á"); str = str.replace(/â/g, "â"); str = str.replace(/ã/g, "ã"); str = str.replace(/ä/g, "ä"); str = str.replace(/å/g, "å"); str = str.replace(/æ/g, "æ"); str = str.replace(/ç/g, "ç"); str = str.replace(/è/g, "è"); str = str.replace(/é/g, "é"); str = str.replace(/ê/g, "ê"); str = str.replace(/ë/g, "ë"); str = str.replace(/ì/g, "ì"); str = str.replace(/í/g, "í"); str = str.replace(/î/g, "î"); str = str.replace(/ï/g, "ï"); str = str.replace(/ð/g, "ð"); str = str.replace(/ñ/g, "ñ"); str = str.replace(/ò/g, "ò"); str = str.replace(/ó/g, "ó"); str = str.replace(/ô/g, "ô"); str = str.replace(/õ/g, "õ"); str = str.replace(/ö/g, "ö"); str = str.replace(/÷/g, "÷"); str = str.replace(/ø/g, "ø"); str = str.replace(/ù/g, "ù"); str = str.replace(/ú/g, "ú"); str = str.replace(/û/g, "û"); str = str.replace(/ü/g, "ü"); str = str.replace(/ý/g, "ý"); str = str.replace(/þ/g, "þ"); str = str.replace(/ÿ/g, "ÿ"); return str; }

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'

Permalänk

function sailor() { return getExternalUrlContent("http://localhost/sailor.php"); } function getExternalUrlContent(url) { var xmlDoc = new ActiveXObject("Microsoft.XMLHTTP"); xmlDoc.Open("GET", url, false); xmlDoc.Send(); try { return xmlDoc.responseText; } catch(e) { return "Error occurred:\n\n" + e.number + " " + e.description; } }

getExternalUrlContent returnerade ingen data tidigare... testa detta istället...

/Anders

Visa signatur

**************************
Om det fungerar för bra, installera om det...

Permalänk
Medlem

Muchas gracias !

Visa signatur

Swec @ 2001 / Chalmerist - Javisst!
'Den som har flest prylar när han dör vinner!'