A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
{ | |
"kariuki": { | |
"home": [ | |
"Buy milk", | |
"Look for pest control service", | |
"Get a new carpet" | |
], | |
"work": [ | |
"Complete the blogpost", | |
"Create presentation for meeting" |
{ | |
"david": { | |
"id":1, | |
"name":"David Ngugi", | |
"verified":1 | |
}, | |
"Victor": { | |
"id":2, | |
"name":"Victor Mwangi", | |
"verified":1 |
{ | |
"rules": { | |
"strict": [ | |
"error", | |
"never" | |
], | |
"import/no-unresolved": [ | |
"error", | |
{ | |
"commonjs": true, |
{ | |
"10100": "Nyeri", | |
"10101": "Karatina", | |
"10102": "Kiganjo", | |
"10103": "Mukurweini", | |
"10104": "Mzeiga", | |
"10105": "Naro Moru", | |
"10106": "Othaya", | |
"10107": "Endarasha", | |
"10108": "Giakanja", |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import urllib.request | |
from bs4 import BeautifulSoup | |
class Scrapper(): | |
def initializeScrapping(self,url): | |
# Set the url of the page you want to scrap for data\ | |
urlpage = url | |
# Using urllib open the page | |
page = urllib.request.urlopen(urlpage) |
class Scrapper(): | |
def initializeScrapping(self,url): | |
# Set the url of the page you want to scrap for data\ | |
urlpage = url | |
# Using urllib open the page | |
page = urllib.request.urlopen(urlpage) | |
#Parse the webpage | |
soup = BeautifulSoup(page, 'html.parser') | |
# Get the page data from the div with a class of product list view | |
producet_list = soup.find('div',class_="prod-list-view") |
... | |
def startScrapping(self,items,book_data): | |
#Get the current working directory | |
current_directory = os.getcwd() | |
# Create a folder named books to store the srapped images | |
path = os.path.join(current_directory,r"books") | |
self.createDirectory(path) | |
counter = 1 | |
#Loop through the product list |
... | |
def createDirectory(self,path): | |
# Create directory to store the images | |
try: | |
os.mkdir(path) | |
except Exception as e: | |
print ("Creation of the directory failed",e ) | |
else: | |
print ("Successfully created the directory %s " % path) | |