(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.
| ... | |
| def main(): | |
| url = "https://textbookcentre.com/catalogue/category/text-books/primary-school/" | |
| scrapper = Scrapper() | |
| scrapper.initializeScrapping(url) | |
| if __name__ == "__main__": | |
| main() |
| ... | |
| 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) | |
| ... | |
| 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 |
| 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") |
| 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) |
(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.
| { | |
| "10100": "Nyeri", | |
| "10101": "Karatina", | |
| "10102": "Kiganjo", | |
| "10103": "Mukurweini", | |
| "10104": "Mzeiga", | |
| "10105": "Naro Moru", | |
| "10106": "Othaya", | |
| "10107": "Endarasha", | |
| "10108": "Giakanja", |
| { | |
| "rules": { | |
| "strict": [ | |
| "error", | |
| "never" | |
| ], | |
| "import/no-unresolved": [ | |
| "error", | |
| { | |
| "commonjs": true, |
| { | |
| "david": { | |
| "id":1, | |
| "name":"David Ngugi", | |
| "verified":1 | |
| }, | |
| "Victor": { | |
| "id":2, | |
| "name":"Victor Mwangi", | |
| "verified":1 |
| { | |
| "kariuki": { | |
| "home": [ | |
| "Buy milk", | |
| "Look for pest control service", | |
| "Get a new carpet" | |
| ], | |
| "work": [ | |
| "Complete the blogpost", | |
| "Create presentation for meeting" |