|
List Info
Thread: Fetching and modifying an external file
|
|
| Fetching and modifying an external file |

|
2006-05-02 23:24:48 |
Using CherryPy, how can I create a page with a link that,
when clicked,
will
1. fetch an external html file (e.g. www.python.org)
2. modify it (e.g. add "Presented to you by
CherryPy" at the top)
3. display it in the browser.
My guess is the following:
1. invoke some CherryPy magic to read
the html file (located at
www.python.org for example) and put the content in a string
2. parse the string to insert <h1>Presented to you by
CherryPy</h1>
right after <body>
3. return that edited string, as usual.
André
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-02 23:43:13 |
Hi,
Andre wrote:
> Using CherryPy, how can I create a page with a link
that, when clicked,
> will
> 1. fetch an external html file (e.g. www.python.org)
> 2. modify it (e.g. add "Presented to you by
CherryPy" at the top)
> 3. display it in the browser.
>
> My guess is the following:
> 1. invoke some CherryPy magic to read
the html file (located at
> www.python.org for example) and put the content in a
string
As far as I know, CherryPy only serves requests, doesn't
make them,
so I'd probably go with urllib2 for fetching the page.
The process will get more complicated if you need to show
the
page with images and CSS-styles (unless python.org, or the
site of
your choice, doesn't use relative links).
> 2. parse the string to insert <h1>Presented to
you by CherryPy</h1>
> right after <body>
> 3. return that edited string, as usual.
Hope this helps,
Ari
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-03 12:11:14 |
I think you'll also need to fetch images and everything the
page
depends on. So if you don't need to put the
<h1>Presented to you by
CherryPy</h1> inside of the opened page, you can use
an iframe for
that.
On 5/2/06, Andre <andre.roberge gmail.com> wrote:
>
> Using CherryPy, how can I create a page with a link
that, when clicked,
> will
> 1. fetch an external html file (e.g. www.python.org)
> 2. modify it (e.g. add "Presented to you by
CherryPy" at the top)
> 3. display it in the browser.
>
> My guess is the following:
> 1. invoke some CherryPy magic to read
the html file (located at
> www.python.org for example) and put the content in a
string
> 2. parse the string to insert <h1>Presented to
you by CherryPy</h1>
> right after <body>
> 3. return that edited string, as usual.
>
> André
>
>
> >
>
--
[]'s,
Luiz Carlos Geron
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-03 15:37:09 |
Perhaps, I should rephrase my query so as to put it in its
appropriate
context.
I using CherryPy to develop a desktop app that takes an
"almost"
completely traditional html based tutorial (with just a bit
of
additional markup) that resides as a series of files on my
computer and
process it to display in a browser with an embedded Python
interpreter
automatically embedded at the appropriate places. What I
would like to
do is to be able to fetch a similar tutorial that resides on
another
computer. This way, people could write python-related
tutorials and
easily share them. For now, I don't worry too much about
embedded
links for css, images or otherwise. My own prototype
tutorial is
straight html files, with no javascript, css, images, etc.
At present, I import local files using
content = open(self.filename, 'r').read()
I then process 'content' within my CherryPy app so as to
embed the
Python interpreter in the appropriate places and
"return" it to display
the result in the browser. I gather, from an earlier
response, that I
simply need to replace open() by a corresponding methods in
urllib
[which I haven't had the time to look up yet.] I was just
wondering if
there was a better way to do this, using a built-in CherryPy
method.
André
Luiz Carlos Geron wrote:
> I think you'll also need to fetch images and
everything the page
> depends on. So if you don't need to put the
<h1>Presented to you by
> CherryPy</h1> inside of the opened page, you can
use an iframe for
> that.
>
> On 5/2/06, Andre <andre.roberge gmail.com> wrote:
> >
> > Using CherryPy, how can I create a page with a
link that, when clicked,
> > will
> > 1. fetch an external html file (e.g.
www.python.org)
> > 2. modify it (e.g. add "Presented to you by
CherryPy" at the top)
> > 3. display it in the browser.
> >
> > My guess is the following:
> > 1. invoke some CherryPy magic to read
the html file (located at
> > www.python.org for example) and put the content in
a string
> > 2. parse the string to insert <h1>Presented
to you by CherryPy</h1>
> > right after <body>
> > 3. return that edited string, as usual.
> >
> > André
> >
> >
> > >
> >
>
>
> --
> []'s,
> Luiz Carlos Geron
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-18 14:16:16 |
By the way, does anybody have some idea how to do this
(fetching
external page with all its content - images, css,
javascripts etc.) in
a simle way?
On 5/3/06, Luiz Carlos Geron <luizgeron gmail.com> wrote:
>
> I think you'll also need to fetch images and
everything the page
> depends on. So if you don't need to put the
<h1>Presented to you by
> CherryPy</h1> inside of the opened page, you can
use an iframe for
> that.
>
> On 5/2/06, Andre <andre.roberge gmail.com> wrote:
> >
> > Using CherryPy, how can I create a page with a
link that, when clicked,
> > will
> > 1. fetch an external html file (e.g.
www.python.org)
> > 2. modify it (e.g. add "Presented to you by
CherryPy" at the top)
> > 3. display it in the browser.
> >
> > My guess is the following:
> > 1. invoke some CherryPy magic to read
the html file (located at
> > www.python.org for example) and put the content in
a string
> > 2. parse the string to insert <h1>Presented
to you by CherryPy</h1>
> > right after <body>
> > 3. return that edited string, as usual.
> >
> > André
> >
> >
> > >
> >
>
>
> --
> []'s,
> Luiz Carlos Geron
>
> >
>
--
S pozdravem
Zdenek Dolezal (zdenek.dolezal gmail.com)
gsm: zdenek.dolezal vodafonemail.cz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-18 14:23:09 |
On Thu, May 18, 2006 at 04:16:16PM +0200, Zdenek Dolezal
wrote:
-> By the way, does anybody have some idea how to do this
(fetching
-> external page with all its content - images, css,
javascripts etc.) in
-> a simle way?
zdenek,
the only general way that I can think of is to use a
proxying setup.
Something like nph-proxy,
http://www.j
marshall.com/tools/cgiproxy/
is build to allow you to "mount" external Web
sites under a local URL.
Unfortunately I don't know of a general proxying solution
for Python
yet; I'm working on one myself, but it's not really ready
for release
just yet. E-mail me off-list if you want to hack around
with it.
cheers,
--titus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-18 14:18:04 |
>
> By the way, does anybody have some idea how to do this
(fetching
> external page with all its content - images, css,
javascripts etc.) in
> a simle way?
I'm sorry but I do not understand the goal here. It looks
suspicious.
- Sylvain
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-18 14:44:33 |
> the only general way that I can think of is to use a
proxying setup.
> Something like nph-proxy,
>
> http://www.j
marshall.com/tools/cgiproxy/
>
> is build to allow you to "mount" external
Web sites under a local URL.
It looks interesting. I'm going to test it.
Thanks for advise.
--
Regards
Zdenek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Fetching and modifying an external file |

|
2006-05-18 14:36:36 |
> I'm sorry but I do not understand the goal here. It
looks suspicious.
Maybe my question wasn't so exact.
Andre wanted to do this:
> 1. fetch an external html file (e.g. www.python.org)
> 2. modify it (e.g. add "Presented to you by
CherryPy" at the top)
> 3. display it in the browser.
I'm solving a problem a little similar like this but if
external page
has any images, css, etc. there is a problem with it using
urllib(2)
and this solution goes really hard to implement. So I asked
if some
has any idea how to do this (in a nice simple way) not using
iframe.
I know this is not a problem of CherryPy but there was this
thread so
I used it. I apologize for that.
---
Regards
Zdenek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|
|
[1-9]
|
|