File size: 538 Bytes
37d3a3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import scrapy
from bs4 import BeautifulSoup
from scrapy.crawler import CrawlerProcess

class MySpider(scrapy.Spider):
    name = 'Daniyal'
    start_urls = ['https://daniy.al']

    def parse(self, response):
        soup = BeautifulSoup(response.text, 'html.parser')

        text = soup.get_text(separator='\n', strip=True)
        filename = 'daniyal.txt'
        with open(filename, 'w') as f:
            f.write(text)
        self.log(f'Saved file {filename}')


process = CrawlerProcess()
process.crawl(MySpider)


process.start()