Я пытаюсь очистить subreddit с помощью Scrapy, но я получаю ошибку 404 при каждом запуске паука.
2020-01-07 12:21:46 [scrapy.spidermiddlewares .httperror] INFO: Игнорирование ответа <404 <a href="https://www.reddit.com/r/gameofthrones//" rel="nofollow noreferrer">https://www.reddit.com/r/gameofthrones//>: код состояния HTTP не обрабатывается или не разрешен
Код, который я сейчас использую:
import scrapy
class RedditbotSpider(scrapy.Spider):
name = 'redditbot'
allowed_domains = ['www.reddit.com/r/gameofthrones/']
start_urls = ['http://www.reddit.com/r/gameofthrones//']
def parse(self, response):
#Extracting the content using css selectors
titles = response.css('.title.may-blank::text').extract()
votes = response.css('.score.unvoted::text').extract()
times = response.css('time::attr(title)').extract()
comments = response.css('.comments::text').extract()
#Give the extracted content row wise
for item in zip(titles,votes,times,comments):
#create a dictionary to store the scraped info
scraped_info = {
'title' : item[0],
'vote' : item[1],
'created_at' : item[2],
'comments' : item[3],
}
#yield or give the scraped info to scrapy
yield scraped_info
Я попытался выполнить повторный запуск после изменения USER_AGENT в файле settings.py, но у меня возникла та же проблема.