Website Logo. Upload to /source/logo.png ; disable in /source/_includes/logo.html

A Coder's Journey

From educator to programmer.

"EXCUSE ME!!! My Computer Broke!"

There she goes. Again.

#Shocking

It's always MY fault. Like there's some sort of magic fairy dust sprinkled on everyone else's computer except *hers*. She even got an instructor to help her this time. Wow. They are going to be in for a tasty treat--look what she put in!

1
2
3
evil_pokemons.each do |pokemons|
Pretty Please scrape the pokemons for me!!!!!
end

Please. Tell me she's joking.

Oh Wait, Shhhh. This is going to be good! She was just asked if she read the Nokogiri tutorial. SAY WHAT???? She DID? She was on that website for .56 seconds. #FACTS. (PLEASE!!! JUST OPEN MY PAGES AND I WILL SPILL ALL! NO SNITCHES GET STICHES FOR ME!!!).

Deep breaths. Let's turn on this fan. Look, I mean, had she read it, she would've seen it's all really quite simple. You just give me a few, quick, straightforward commands at the top of your page, and I make like a shepherd and flock!

1
2
require 'nokogiri'
require 'open-uri'

You can even put these commands into irb to play around with, and I will set up your ENTIRE environment perfectly (just make sure I return "true" after each command).

Next, kindly let me know what language you would like to use (I'm very versatile), and for heaven's sake don't be lazy, name your document something fun--'doc' is just so uneventful.

1
2
html = open('website').read
doc_name = Nokogiri::HTML(html)

Now, you are at the part where you get to chillax. Open up your browser by right clicking in crome on inspect element, and you should be able to use the nifty magnifying glass to help you locate any element's css selector you would like on the page.

Once you've found the css selector of your desired element-try it out-I mean, you wouldn't buy a car without test driving it first, why should scraping be any different? Feel free to use binding.pry, a simple puts command, or the beautiful world of irb!

1
2
variable_doc.search(" ").text
variable_doc.css(" ").text

.search and .css mean the same thing, so don't cry your pretty little eyes out about that! Once you've successfully matched the css selector to your element you are good to go and can head right back to your ruby program. Adding .text at the end returns--you guessed it--the text that your css selector selected! I will take care of all the rest (like I ALWAYS do 😘).

Jimmy Jet and His TV Set