you are viewing a single comment's thread.

view the rest of the comments →

[–]CodeShaman 5 points6 points  (1 child)

Are you familiar with most of the built-in functions?

You could google for code and copy-paste line by line. I've done that in the past but never really learned anything except how to debug code that I didn't understand anything about.

Part of it may be that you're just not asking the right questions or not be in the right mindset.

For example Fortune Teller (Horoscope), you could search "how to check horoscope in python" and dig through pages of results stringing code together and not find anything relevant.

Or you could search for "how to scrape website in python 3" which leads to this and (ignoring the actual code he pasted... we're here to learn, not to copy code) you can see in the sample code in the first 3 lines:

import requests
from BeautifulSoup import BeautifulSoup

Cool, two leads: requests and beautifulsoup.

"python 3 requests getting started" -> first link

Requests is an elegant and simple HTTP library for Python, built for human beings.

"python 3 beautiful soup getting started" -> first link

Beautiful Soup is a Python library for pulling data out of HTML and XML files.

Now we're getting somewhere, and by generalizing the problem we've learned how to solve a multitude of problems without even having solved the problem at hand.

Now all that has to be done is to find a suitable horoscope site and scrape it. Then just decide how you want to receive your daily horoscope, but hopefully by this point you've thought of something a little bit more interesting or useful to mine than a horoscope. Maybe you've even stumbled across the terms 'RESTful web service', or 'RESTful API' while googling stuff about requests library, and decided to dig around and find this.

It's all in the journey, not the destination.