Page 1 of 1

httpRequest to get data from other domains, or how can I show informations from other websites?

Posted: Sat Jan 20, 2024 10:21 pm
by xaby

Code: Select all

site$ = "https://www.google.com"

;-------> SpiderBasic

   Procedure HttpGetEvent(Success, Result$, UserData)
     If Success
       Debug Result$
     Else
       Debug "HTTPRequest(): Error"
     EndIf
   EndProcedure

  ; Get the content of this file, and display it in the debug window
   ;
   HTTPRequest(#PB_HTTP_Get,site$, "", @HttpGetEvent())


;-----------> PureBasic ------------->

;   HttpRequest = HTTPRequest(#PB_HTTP_Get, site$)
;   If HttpRequest
;     Debug "StatusCode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
;     Debug "Response: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
;     
;     FinishHTTP(HTTPRequest)
;   Else
;     Debug "Request creation failed"
;   EndIf
I know, it is a rights problem, and localhost is not allowed to get information from other websites and if that SpiderBasic program would be on the samve server, it would work. I want to get information from other domains as well. In PureBasic that would work. Do I have any chance, to get that done with SpiderBasic? Or do I need to run somehow a PureBasic program on my Webserver. How would I need to setup the CGI? My website would be on a normal Webserver-Hosting-contract from Strato. So no V-Server. Could that be even possible or would I need something else?

Is it possible to include "iFrames" or information from other websites, like YouTube videos?
Or some text as teasers from other sites? Do I have to download sites from other servers?

Thanks for help.

Re: httpRequest to get data from other domains, or how can I show informations from other websites?

Posted: Sat Jan 20, 2024 10:44 pm
by plouf
no, it has to do with CORS , client side (browser) restriction

ANYTHING that runs in your server, including php server side scripting can access ,and send this back to your SpiderBasic Script

Re: httpRequest to get data from other domains, or how can I show informations from other websites?

Posted: Sun Jan 21, 2024 2:50 pm
by xaby
Yeah, that was, what I thought.
Is it somewhat possible to use PureBasic instead of PHP? Or does it make not much sense?
Thanks for help.

Re: httpRequest to get data from other domains, or how can I show informations from other websites?

Posted: Sun Jan 21, 2024 10:36 pm
by plouf
in order to use purebasic to write a CGI app, is possible but you need to run your own cgi exe in server and config server to execute it.
This is very rare at hosting companies, practically only possible with your own server and/or VPS (which is actualy again your own server)
also depended on hosting policy, iti is possible that not even self hosted php script would allowed to connect outside...

if the target group of the users of your app is going to be a closed trusted group of people, lets say your colleagues if its a inhouse tool.
You can install a CORS plugin in firefox/edge in order to allow it.
But as ou can understand this is not going to work widely.....