The Internet is full of information that you can use in your programs. For example in Lab 4, you will write an block that looks up the weather forecast for your location and tells you whether or not to carry an umbrella. You'll also build a
current temperature
block that reports the current temperature for a certain location:
http
block is reporting?http
block reported?The output of the http
block is the HTML code that creates the page at the address in the input slot.
Every web page has a head (that tells the browser how to format the page) and a body (that contains the actual information on the page). You'll see something more interesting if you skip over the head by looking for the text "<body":
There are two custom substring
blocks included in this project. They each report only a portion of a text string:
substring starting with
block reports the part that starts with the text you enter in the input slot.substring up to
block reports only the part up to the text you enter in the input slot.
For example, if the variable string contains "This is an example of the substring blocks.", then the two substring blocks will report:
http
block with a different URL. (Hint: it's probably not going to work. So, just try it and keep reading.)
http
block.You very likely got an empty result back. This is due to a security feature. One web site (such as the Snap! server) is not allowed to send a request to another site. Fortunately for us, it's not a very solid attempt at security...
The proxied http
block works by fooling the other web site into sending you data it wouldn't normally send. Most websites receive a request coming from Snap! and say "this isn't a real web browser query, so I'm not answering." The proxied http
block uses proxy (a replacement or stand-in) servers (in this case, alloworigin.com) to call the URL you enter. The proxy server performs the request properly (as a browser would), gets the information, and sends it to Snap! as though things went smoothly.
In short, the proxied http
block works the way we want the http
block to work.
A security feature of what? Snap!? The browser? --MF
I'm not sure, actually. Not Snap!. Probably the browser. --bh