Quiz
- in this reading at the Sessions part, we save login_resp.cookies into a variable and then pass cookies= session. is there any difference between doing that or just creating a request.session()?
I think you are confusing the session in the Flask program with the session in the Python program using the
requestsmodule. (Understandable, since they are two sides of a conversation, and neither side can drop the ball.- The Flask program is the server. It
uses
request.sessionto get the session (the "ball") from the client. It can manipulate it, like putting the userid into it after a successful login. It then passes the ball back to the client. - The Requests (Python program using the
requestsmodule) is the client, taking the place of the browser. It uses a global variable in place of a cookie jar, so that it can pass the "ball" back to the the server on the next request.
I should do a better job explaining this in the reading. Thanks for this question!
- The Flask program is the server. It
uses
- I know I've used Beautiful Soup before but it's been a long time and I forgot what it does?
It parses HTML (like a web page) and gives you an API for searching it and even modifying it. Useful for web scrapers and the like. You can pass a web page to Beautiful Soup and then just ask it for all the hyperlinks (
Atags) on the page. You can extract the URLS (hrefattribute) and then make requests to those URLs.