rust-community/rustbridge

Idea for Rust workshop - Parser app with content from web

hannelita opened this issue · 12 comments

  • Run the Rust meetup in Sao Paulo on Aug 3rd
  • Get people's feedback
  • write a list of topics to be covered in the workshop
  • Describe how the tasks and concepts will be presented and taught
  • Describe an example app
  • Propose the app that will be built by the attendees

Possibly due to Aug 10

Good news - we ran the meetup and got some feedback from the audience. I proposed some suggestions here: http://slides.com/hannelitavante-hannelita/rust-html-parsing and did some code here (check through the different branches) https://github.com/galois1/demo . The code describes a possible alternative to guide the course of the workshop.
It was nice, we collected plenty feedback.

img_20160803_205439784
(It was much better than I expected!)

Topics to cover:

  • Explain some use cases for parsers
  • Explain the basics of the structure of a web page - HTML and CSS crash course (tags, classes, etc)
  • Explain the logic to collect these elements from a web page
  • How can we establish a conversation with a web page to collect this data? Explain the basics of HTTP and GET.
  • Start a sample code with Rust
    • Question: Should we explain the structure of a Rust project in this workshop? if yes, we can start with Cargo (assuming people will have Rust on their machines), hello world, project dependencies and packing. Explain main.rs file format and introduce the idea of functions
  • Explain that it would be a lot of work to build an entire tool to handle HTTP protocol - and then introduce Hyper (or any other lib to handle that). Build the basics for a client. This step would be similar to https://github.com/galois1/demo/blob/master/src/main.rs
  • Explain extern + imports. Type the code without declaring the use, intentionally make it break and then explain we need to invoke hyper (or any other lib).
  • Explicitly select a page to scrape - can be any page, maybe rust docs? I gave an example with amazon, but it may not be interesting to all the participants. Maybe we should use Mozilla content to scrape.
  • Scrap a page with Hyper (or any other lib). Get the full HTML. Print it, then save it in a file. We can explain Strings and I/O here. Somethings like this: https://github.com/galois1/demo/blob/improv1/src/main.rs
  • Show that handling a huge HTML file to collect specific pieces of data would be a lot of work. Introduce some lib to handle that, such as select (or any other lib).
  • Add select on Cargo.toml and import it.
  • Suggested by the audience - write a verbose, non-inline/chained code, using select to transform the scraped page.
  • Write a bunch os distinct functions, a Struct, an Impl and show a more robust or more organised code example, such as in https://github.com/galois1/demo/blob/improv2/src/main.rs

explain some use cases for parsers ... I think that is an interesting point: to make a compelling 'story' because that helps people to follow the more abstract parts (which have to be there as well).

I have started on the extern crate / dependency thing for graphics already but only on the surface; as much as I had to get the prerequisite graphics example working.

How much IT/Web/Coding experience did your audience have?

@broesamle everyone was a software developer, but I mentioned we were willing to aim ppl without experience

Rotating @hannelita's image :)

5b430f62-5e4f-11e6-8dde-6e44e9bf382e

Extra suggestions by the audience:

  • Rust fmt
  • Explain how to use docs
  • Make sure the place ahs internet connection

/cc @brson, given we've chatted quickly about it on #rust-community

@hannelita I've started to draft out some outline for the slide content given the example code and the notes on this PR.

I've put it on this file so GitHub could render it nicely:
https://github.com/bltavares/presentations/blob/rust-html/introdution-to-rust-parsers/presentation.org

There is a repository with the code up to the download page here:
https://github.com/bltavares/presentations/tree/rust-html/introdution-to-rust-parsers/listr

Each commit on this directory is one part of the content presented on the slides outline:
https://github.com/bltavares/presentations/commits/rust-html/introdution-to-rust-parsers/listr

Is any of this helpful for the workshop? I could transfer the content and the commit to a separate repo as well, it was just an easy place for me to put it.

Migrating over from #12:

@Manishearth recommended using kuchiki for the web scraping.

brson commented

Thanks @bltavares ! A few of us at the SF meetup are going to try to continue with this material.