You are invited to Log in or Register a free Frihost Account!

Pulling quotes from wikiquote


I hope someone can help me with this idea I have in my head. I'm quite new to webdevelopment but as I'm an engineer I have that engineer's mentality i.e. I learn to build (meaning I'm willing to learn a scripting language to complete my task).

So does anyone know how I can pull out a random quote off the fantastic Wikiquote website and display it on my own page.

I would ideally like to filter this "search" (by author or subject) and display a different quote on my website at a click of a button.

I read somewhere that I can pull quotes from a text file using php but would prefer to pull the quotes from wikiquote.

Thanks a bunch.
I did a script in PHP that pulled a random quote from (A random Chuck Norris facts page) by using their random rss feed generator. Since a random quote always appeared on the same line in the rss feed, I was able to simply read the entire rss file into an array in PHP by using the file('filename') function.

However, the thing with Wikiquote is that each page is signifigantly different, due to the input from a multitude of users. However, the one constant is that all the quotes appear to be in an <li> tag. Therefore, it is concievable that you could filter the page down to just the <li> tags, and then simply use a function that looks like

$x = count($arrayWithQuotes) - 1;
echo $arrayWithQuotes[rand(0,$x)];

to display a random quote.

But that still needs the ability to go to a random page. But since you're keen on the search feature, a possibility is that you could have a user ask for a random quote from a partiicular person, and then you could grab a random quote from that page. Alternatively, you could keep a list of random people, and then pick a random quote from a random person.

It's still gonna take a lot of work, mostly because Wikiquote is so irregular, but that should do for a couple of starting pointers.
i`m gonna pm you if i find a script i did about half a year ago for a gsm company.. the script tooked as input a page and tooked out of it all the infomration and store it in different variables, and the website from where it got the info was really messed up. I`ve worked on it alot, and it would be easy to adjust it to your needs. Just hope i find it, since i`ve changed my job two months ago Cool
You guys are legends in the making. Thanks for your help and I look forward to the pm!
Ooh! A legend!
Related topics
Great One-Liners & Quotes
Love And Friendship Quotes
Google's Search Engine Performance Drop
Random Quotes Services for anyone - 1 Frih$ for 170+ quotes
Embarrassing newbie php/SQL questions
Do We get points for quotes?
[PHP] HTML entities, inputs, quotes
Anchorman quotes
Collection of the most memorable quotes by FriHost members:)
A debate of religion, science, and more
Favourite Dumbledore Quotes
Linux Quotes [:d]
Let's coin a new term!!!!! Pulling a Alkady!!!
Christianity: Why so many Churches? / Denominations?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.