HTTP: Difference between revisions

265 bytes removed ,  3 years ago
m
Removed comments, updated whitespace, URL.
m (Updated URL.)
m (Removed comments, updated whitespace, URL.)
Line 1,609:
{{libheader|RCurl}}
{{libheader|XML}}
 
First, retrieve the webpage.
<lang R>library(RCurl)
 
webpage <- getURL("http://rosettacodewww.w3.org/Home.html")
<lang R>
webpage <- getURL("http://www.rosettacodew3.org/Home.html", .opts=list(followlocation=TRUE))
library(RCurl)
webpage <- getURL("http://www.w3.org/Home.html", .opts=list(proxy="123.123.123.123", proxyusername="domain\\username", proxypassword="mypassword", proxyport=8080))</lang>
webpage <- getURL("http://rosettacode.org")
 
#If you are linking to a page that no longer exists and need to follow the redirect, use followlocation=TRUE
webpage <- getURL("http://www.rosettacode.org", .opts=list(followlocation=TRUE))
 
#If you are behind a proxy server, you will need to use something like:
webpage <- getURL("http://rosettacode.org",
.opts=list(proxy="123.123.123.123", proxyusername="domain\\username", proxypassword="mypassword", proxyport=8080))
#Don't forget that backslashes in your username or password need to be escaped!
</lang>
 
Now parse the html code into a tree and print the html.
<lang R>library(XML)
 
pagetree <- htmlTreeParse(webpage )
<lang R>
pagetree$children$html</lang>
library(XML)
pagetree <- htmlTreeParse(webpage )
pagetree$children$html
</lang>
 
=={{header|Racket}}==