0

I'm making a glue script for in php stitching together two pieces of software (IBM's TNPM and Network Weathermap). To get weathermaps OVERLIBGRAPH functionality working i need the url of the graphs that TNPM produces (which are PNGs).

Now TNPM does not seem to have an API to do it, nor are the urls for these graphs very predictable. I dont know much about TNPM, so I might be wrong here. So im treating it as a web application and I try to scrape the graph url from a page which contains this graph.

however my script is on a firewalled server and normally gets its input via a dump. it cannot really access TNPM (by this I mean I cannot use a proxy solution). my boss tells me that opening the firewall so my glue script can access the TNPM server like a normal user is going to take a long time.

So I'm hoping to use javascript to scrape the page from inside the users browser (which presumably is logged in to TNPM). however I am going to run into the same origin policy this way.

it needs to work in internet explorer 8. other browsers cannot get the graphs i want directly (probably due to some sniffer on TNPM banning other browsers).

I dont know a solution, but maybe anyone know a way around the cross origin policy which might work in this case?

update: the problem will be solved from the server side by opening the firewall. So I dont need an answer anymore, although i'd still appreciate it.

timwaagh
  • 303
  • 3
  • 14
  • I have read the answers in the other question. They dont solve my problem as they all use server side adaptations or web services. either by having the server serving the mashup fetch the html (act as a proxy) or the server that gets scraped should serve data in a specific format. – timwaagh Nov 05 '14 at 13:37

1 Answers1

0

I would try the following article which looks promising, from: Mads Kristensen

Basically, it's taking advantage of the breach to change document.domain via JavaScript and allow communication between an iframe and its parent that are on the same domain, by using a proxy server that points to the IP of the website you want to pull data from.

E.G:

Site domain - a.mysite.com

"Other" domain - www.articles.com

The proxy server domain - b.mysite.com (points to "www.articles.com" IP, as an A record in the DNS)

Usage:

  1. a.mysite.com implements an iframe with src="b.mysite.com" and sets document.domain = "mysite.com"
  2. b.mysite.com sets document.domain = "mysite.com"
Yonatan Ayalon
  • 1,959
  • 18
  • 19
  • I cannot do a proxy solution because I cannot change the firewall settings and it seems to block any outgoing connections (curl whatever.com doesnt work). im looking for a strictly client side solution. – timwaagh Nov 05 '14 at 12:07