Prototyping 7 May 2013: Difference between revisions
No edit summary |
|||
Line 24: | Line 24: | ||
<source lang="python"> | <source lang="python"> | ||
import cgi, urllib2, html5lib, urlparse | import cgi, urllib2, html5lib, urlparse | ||
import cgitb; cgitb.enable() | import cgitb; cgitb.enable() | ||
print "Content-type: text/html" | print "Content-type: text/html;charset=utf-8" | ||
print | print | ||
q = cgi.FieldStorage() | q = cgi.FieldStorage() | ||
url = q.getvalue("url","http://pzwart3.wdka.hro.nl/wiki") | url = q.getvalue("url","http://pzwart3.wdka.hro.nl/wiki") | ||
f = urllib2.urlopen(url) | f = urllib2.urlopen(url) | ||
t = html5lib.parse(f,treebuilder="etree",namespaceHTMLElements=False) | ct = f.info().get("content-type") | ||
if ct.startswith("text/html"): | |||
t = html5lib.parse(f,treebuilder="etree",namespaceHTMLElements=False) | |||
for a in t.iter("a"): | |||
for a in t.iter("a"): | href = a.get("href") | ||
href = urlparse.urljoin(url, href) | |||
print '<a href="?url={0}">{0}</a><br>'.format(href) | |||
</source> | </source> | ||
== Ideas for browsers == | == Ideas for browsers == | ||
* ... to be filled in / linked to ... | * ... to be filled in / linked to ... |
Revision as of 11:48, 13 May 2013
Alternative Browsers
- Screen Readers
- http://www.youtube.com/watch?v=NCs48NjhHRg
- http://www.youtube.com/watch?v=6kDPHnKlpd4 | older demo showing general PC interface for blind
- http://www.youtube.com/watch?v=-zSTJwIULYU | demo showing JAWS
- webstalker
- CGI / html5lib...
- Python on OSX:
install OSX command line tools - > https://github.com/kennethreitz/osx-gcc-installer/ install homebrew - > http://mxcl.github.io/homebrew/
CGI Hello Browser
import cgi, urllib2, html5lib, urlparse
import cgitb; cgitb.enable()
print "Content-type: text/html;charset=utf-8"
print
q = cgi.FieldStorage()
url = q.getvalue("url","http://pzwart3.wdka.hro.nl/wiki")
f = urllib2.urlopen(url)
ct = f.info().get("content-type")
if ct.startswith("text/html"):
t = html5lib.parse(f,treebuilder="etree",namespaceHTMLElements=False)
for a in t.iter("a"):
href = a.get("href")
href = urlparse.urljoin(url, href)
print '<a href="?url={0}">{0}</a><br>'.format(href)
Ideas for browsers
- ... to be filled in / linked to ...