http
block with a different URL. It likely won't work, but try it, and keep reading.Use the U4L3-HttpBlock file as a starter project for any web scraping app you build; it has proxied http
and the substring
blocks already installed.
proxied http
block uses proxy (replacement or stand-in) servers to call the URL you enter. The proxy server performs the request as a browser would and sends the information to Snap!.You likely got an empty result back. For security, a website (such as the Snap! server) is not allowed to send a request to another website. Servers expect browsers to send website requests.
There is a JavaScript program in this Snap! project called proxied http
that uses a proxy (stand-in) server to fool the requested web site into sending data it wouldn't normally send.
proxied http
to Access WebsitesThe proxied http
block will allow you to program Snap! to access websites as part of your projects. After accessing a site, you'll need to isolate the specific information you want from the HTML. Extracting the information out of the formatting is called scraping the web page.
proxied http
doesn't work?proxied http
doesn't work, you can skip the remaining pages in this lab. You might find them interesting to read, but will not be able to do the projects. If you have access to the Internet somewhere that this block works, you can use Snap! to code web scraping projects such as a Weather App.
proxied http
block if your network has certain security settings (like a firewall) that prohibit using proxy servers to access blocked content.Like the two custom substring
blocks, which you can use to extract specific information from a webpage, you can also use split
to manage the complex data returned from an HTTP query. Use split
to break up a long string of text into a list of smaller strings according to some marker (spaces, tabs, commas, new lines, etc.).
www.wunderground.com/cgi-bin/findweather/getForecast?query=New+York,NY
substring
block to write a script that reports a list of the lines of HTML starting from <div id="current"
and store that list as a variable (such as weatherdata).Many websites communicate information in the details in their URLs.
ask
are available from a reporter called answer. As before, use the error reporting http
. How much of the JavaScript (JS) function can you read?
!
for =
for if else
and return
work the same as in Snap!.Your IP address contains information about your location, and apps can access this information.
proxied http
block: