Collections are covered by copyright. So even though a recipe is not copyright-able, a book containing recipes is. One of the reasons you will see recipes filled with many paragraphs of filler is that it then becomes a literary work which is covered by copyright.
Having said that, I would be surprised if the majority of code in SO is generally copyright-able. If I ask a question, "How do I initialise an object in C++" and the answer is a few lines of code, I do not think that this is a copyright-able work. It is a technique. Even if the code is long enough to be copyright-able, I don't think using the technique would be considered a derived work.
Whatever the case, scraping portions of SO would be a copyright violation since it is a collection.
you still can do that and attribute it somewhere. doubly so with this change, since they require a link and it could be a qr code on the margin (not that I'd buy that book, still..)
Having said that, I would be surprised if the majority of code in SO is generally copyright-able. If I ask a question, "How do I initialise an object in C++" and the answer is a few lines of code, I do not think that this is a copyright-able work. It is a technique. Even if the code is long enough to be copyright-able, I don't think using the technique would be considered a derived work.
Whatever the case, scraping portions of SO would be a copyright violation since it is a collection.