0

Here My code which i made:

import json
from pyspider.libs.base_handler import *

f = open("demo.txt","w")
class Handler(BaseHandler):
    crawl_config = {
    }

    @every(minutes=0,seconds = 0)
    def on_start(self):
        self.crawl('Any URL', callback=self.index_page)

    @config(priority=2)
    def detail_page(self, response):
        img = ""
        for each in response.doc("img[id='landingImage']").items():
            img = each
        f.write("\n"+response.doc('title').text() + "\t" + response.doc("span[id^='priceblock']").text())
        return {
            "url": response.url,
            "title": response.doc('title').text(),
            "img_url":img.attr['src'],
            "Price":response.doc("span[id^='priceblock']").text(),
            "Availability":response.doc("div[id='availability']").text()
        }

In above code i have scrap data from link but i can not get output in json or csv format

enter image description here

Piyush
  • 511
  • 4
  • 13

1 Answers1

0

You can download the data from webui, or append the data to a file by override on_result method.

Binux
  • 697
  • 6
  • 12