This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(venv) (base) C:\Users\Shritam\Desktop\Scrapy\venv\iscrapy>scrapy crawl Thespider -o book_data.csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
books = response.css('ol.row') | |
for book in books: | |
for b in book.css('article.product_pod'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data['Title'] = b.css('a::attr(title)').getall() | |
data['Price'] = b.css('div.product_price p.price_color::text').getall()[0].split()[0] | |
data['Stock'] = b.css('div.product_price p.instock.availability::text').getall()[1].strip() | |
data['Star'] = b.css('p::attr(class)').getall()[0].split()[-1] | |
data['Star'] = [j for i,j in dic.items() if i in data['Star']][0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inp = int(input("Enter the no. of pages you want to scrap: ")) | |
class ThescrapySpider(scrapy.Spider): | |
name = 'Thescrapy' | |
start_urls = ['http://books.toscrape.com/catalogue/page-{}.html'.format(n) for n in range(1,inp)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(venv) (base) C:\Users\Shritam\Desktop\Scrapy\venv\iscrapy>scrapy genspider TheSpider books.toscrape.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import scrapy | |
class ThespiderSpider(scrapy.Spider): | |
name = 'TheSpider' | |
allowed_domains = ['books.toscrape.com'] | |
start_urls = ['http://books.toscrape.com/'] | |
def parse(self, response): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(venv) (base) C:\Users\Shritam\Desktop\Scrapy\venv\iscrapy>scrapy genspider iscrapy books.toscrape.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(venv) (base) C:\Users\Shritam\Desktop\Scrapy\venv>scrapy startproject iscrapy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(venv) (base) C:\Users\Shritam\Desktop\Scrapy\venv>pip install scrapy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(base) C:\Users\Shritam\Desktop\Scrapy\venv>Scripts\activate.bat |