Skip to content

Commit

Permalink
Add logger for scrapy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tan 🔥 committed Jan 12, 2023
1 parent 94edb4c commit a4346c9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crawl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# go to the spider directory
cd /opt/repo/project
# run the spider
/usr/local/bin/scrapy crawl product -a location=$1
/usr/local/bin/scrapy crawl product --logfile $2 -a location=$1
1 change: 1 addition & 0 deletions project/project/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ class ProjectItem(Item):
rating_value= Field()
rating_count= Field()
sold_by = Field()
location = Field()
1 change: 1 addition & 0 deletions project/project/spiders/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}

class ProductSpider(scrapy.Spider):
name = 'product'

def __init__(self, **kwargs):
self.name = 'product'
Expand Down
2 changes: 1 addition & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pip3 install -r requirements.txt
# Create a cron job to run the scraper at 12am and 12pm
sudo service cron start
echo "0 */12 * * * (/bin/bash /opt/repo/crawl.sh Paris 2>&1) > /var/log/cron/spider_log.log" | crontab
echo "0 */12 * * * (/bin/bash /opt/repo/crawl.sh Paris /var/log/cron/spider_log.log)" | crontab
EOF

Expand Down

0 comments on commit a4346c9

Please sign in to comment.