Pulling quotes: is there a way to pull quotes from a website?


I am looking to pull different sayings in Irish of a website, for my random quote generator. Do I need to manually rewrite them, or can I pull them off the website? I am just wondering if there is a way to do it? I can’t think of a way. unless the information is blocked.


Google search “web scraping”


Yes, as jenovs says, web scraping is an option, but that is going to get you into a completely different level of complexity that far exceeds what is needed for this project.

There are two main approaches to getting the quotes.

One is to use an ajax call. This is where the web site has specifically set up a server, a program that will respond to a request from your program for a quote by sending you a quote. Most web sites do not have this set up. Two of the ones commonly used in this way are forismatic and quotesondesign. It’s unlikely that youre Irish quote site has one set up, but you can search for it with the phrase “api” and see if there is one.

For the second way, if you really, really have your heart set on those Irish quotes, another simple option would be to hard code them into an array in your program and then select them at random. This is what I ended up doing because I wanted music quotes. (Don’t worry, you’ll get plenty of chances to practice ajax on other builds.)

Yes, there are ways to extract the quotes from the site, but it is going to be a Pandora’s Box of stuff you are going to have to learn just to finish this simple build. My advice is to keep it simple and focus on what you’re trying to learn. You can always come back after your certificate and make it more complex. But if you get bogged down in complexity, you may get confused and frustrated.


Also if you want your quotes and still practice ajax you can use myjson.com

Basically you write your own JSON with the quotes you want, upload it to this website and get a link to an API which you can call through AJAX. :slight_smile: