Page 1 of 1

Open web page

Posted: Thu Apr 11, 2024 12:49 am
by WilliamL
In my program I want to be able to use code to run Safari and go to a specific page (e.g. https://world-weather.info/forecast/usa ... arch-2023/) I don't need to read the contents or anything I just want to look at it.

I'm sure I saw this somewhere...

Re: Open web page

Posted: Thu Apr 11, 2024 1:32 am
by Quin

Code: Select all

RunProgram("open", "https://world-weather.info/forecast/usa/everett/march-2023/", "")

Re: Open web page

Posted: Thu Apr 11, 2024 3:31 am
by WilliamL
Thanks Quin,

Works perfectly! I was playing with RunProgram but couldn't get the right combination.

Re: Open web page

Posted: Sat Apr 13, 2024 12:15 pm
by Piero
WilliamL wrote: Thu Apr 11, 2024 3:31 am I was playing with RunProgram but couldn't get the right combination.

Code: Select all

#helppath$="/Applications/PureBasic.app/Contents/Resources/help/purebasic/"

Procedure.s sh(search$)
   Protected Output$, shell
   shell = RunProgram("/bin/sh","","",
      #PB_Program_Open|#PB_Program_Write|#PB_Program_Read)
   If shell
      WriteProgramStringN(shell,search$)
      WriteProgramData(shell,#PB_Program_Eof,0)
      While ProgramRunning(shell)
         If AvailableProgramOutput(shell)
            Output$ + ReadProgramString(shell)
         EndIf
      Wend
      CloseProgram(shell)
   EndIf
   ProcedureReturn Output$
EndProcedure

Procedure pbh(s.s)
   s=#helppath$+sh("grep -i '"+s+"' "+#helppath$+~"index.xml  | awk -F'\"' '{ print $(NF-1) }' | head -n 1")
   if s <> #helppath$

      sh( "open -a safari " + URLEncoder(s) )

   EndIf
EndProcedure

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

pbh("runprogram") ; PB Help in Safari