Display text from another web site

L

Linda

Is it possible to retrieve text from an external website and display
that text within my own page?

As an example, can I grab the text from a div that has a class of
"legal" from this web site and display it within my page?

http://www.cinsoft.net/mylib.html ;-)

Linda
 
D

Denis McMahon

Is it possible to retrieve text from an external website and display
that text within my own page?

As an example, can I grab the text from a div that has a class of
"legal" from this web site and display it within my page?

http://www.cinsoft.net/mylib.html ;-)

Hmm, crudely, you could grab the whole page using an xhr in an onload,
try to pull out the text you wanted, and display it.

How well it would work I don't know. There may be other methods.

Rgds

Denis McMahon
 
R

Ry Nohryb

Is it possible to retrieve text from an external website and display
that text within my own page?

No. Not unless you do it server-side. Orot unless you are using a very
very current browser, one than can do cross-site xhrs, and then only
if you can count on the collaboration of the remote server
(cinsoft.net in this case).
As an example, can I grab the text from a div that has a class of
"legal" from this web site and display it within my page?

http://www.cinsoft.net/mylib.html ;-)

Just ask David :)
 
G

Garrett Smith

Yes. Check "Ajax cross-domain" athttp://winhlp.com/node/699 for
an example with code.
In your JSP example, why all that Java code? Why not use c:import instead?
 
S

Sean Kinsey

Is it possible to retrieve text from an external website and display
that text within my own page?

As an example, can I grab the text from a div that has a class of
"legal" from this web site and display it within my page?

http://www.cinsoft.net/mylib.html ;-)

You can use YQL to do this, eg. with the query
select * from html where url="http://www.cinsoft.net/mylib.html"
and xpath='//div[@class="legal"]'

Use this for JSONP:

http://query.yahooapis.com/v1/publi...[@class="legal"]'&format=json&callback=cbfunc

And here is the console where you can test queries

http://developer.yahoo.com/yql/cons...mylib.html" and xpath='//div[@class="legal"]'

Sean
 
S

Stone Zhong

Is it possible to retrieve text from an external website and display
that text within my own page?

As an example, can I grab the text from a div that has a class of
"legal" from this web site and display it within my page?

http://www.cinsoft.net/mylib.html ;-)

Linda

iframe?

XHR does not allow cross-domain visit, and dynamic adding <script> tag
requires the web site returns javascript instead of plain text or html
document.

- Stone
 
G

Garrett Smith

No idea. I didn't write that, just picked it up somewhere and
adapted it a little.

Can you just use an otherwise empty page, apart from some
minimal header, and just one c:import tag in it that points to
an external URL?

Sounds really nice. Why haven't I seen that tag anywhere?
Perhaps I'm still using an older JSP version that didn't have it
yet.
c:import's been around for years. 5 years, is it now? Not sure.

I used:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:url value="http://suggestqueries.google.com/complete/search"
var="url">
<c:param name="qu" value="${param.q}"/>
<c:param name="jsonp" value="${param.jsonp}"/>
</c:url>
<c:import url='${url}'/>

Seeing my web host has committed the downgrade and as a bonus, provided
a completely new configuration of tomcat, breaking the entire site. They
even gave me a new password.

The web host is dailyrazor.com and I do not recommend them.

I'll have to go and fix that.

So I can't show you a demo, but that's the way c:import works.
 
D

David Mark

No. Not unless you do it server-side. Orot unless you are using a very
very current browser, one than can do cross-site xhrs, and then only
if you can count on the collaboration of the remote server
(cinsoft.net in this case).



Just ask David :)

I think it's been covered fairly well already. In general, you would
need a server side process of some sort. There are some canned
solutions out there.

Assuming this is not an academic example, I want to assure users of My
Library that you do not have to maintain up-to-date copyright notices
on your works. In fact, you don't have to display my copyright at all
(though it must remain in the source code).
 
L

Linda

Assuming this is not an academic example,

It was an academic example. I just used your web site since I know
you and you had a class name that I just plucked out of your web
page. I could have chosen any other class name for the example or
anyone else's web page.

Linda
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top