found something that seems to work (after some modifications)
#http://chase-seibert.github.io/blog/2011/01/21/youtube-detecting-x-frame-optionsframebreaking-in-python.htm
def Is_Framing_Allowed ( URL ) :
import urllib2
req = urllib2.Request ( URL )
##req.add_header ( "Referer", "http://example.com") # you should
put your real URL here
try :
opener = urllib2.urlopen ( req )
except :
return False
# returns True if ANY x-frame-options header is present
# the only options at present are DENY and SAMEORIGIN, either of
which means you can't frame
return not "x-frame-options" in opener.headers.dict
On 16-02-14 1:26, Stef Mientki wrote:
hello,
I want to show external sites in an IFRAME (including the link to the
orginal site),
so I can add comment to the external website,
but some sites won't show in an IFRAME.
This seems to e due to X-Frame options.
Is there a way to detect if there are any x-frame-options,
so I can make a choose to display the site in an IFrame or as a direct
link to the externa website?
thanks,
Stef
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.