【发布时间】:2020-09-09 16:11:23
【问题描述】:
我最近开始学习在 python 中使用 Scrapy 进行 Web 抓取,并面临从 AccuWeather.org 网站 (https://www.accuweather.com/en/gb/london/ec4a-2/may-weather/328328?year=2020) 抓取数据的问题。 基本上,我正在捕获日期及其天气温度以用于报告目的。 在检查该站点时,我发现太多 div 标签,因此对编写代码感到困惑。因此,我想我会寻求专家的帮助。
这是我的代码供您参考。
import scrapy
class QuoteSpider(scrapy.Spider):
name = 'quotes'
start_urls = ['https://www.accuweather.com/en/gb/london/ec4a-2/may-weather/328328?year=2020']
def parse(self, response):
All_div_tags = response.css('div.content-module')[0]
#Grid_tag = All_div_tags.css('div.monthly-grid')
Date_tag = All_div_tags.css('div.date::text').extract()
yield {
'Date' : Date_tag}
我在 PyCharm 中编写了此代码,但由于“代码未处理或不允许”而出现错误。 请问有人可以帮我吗?
【问题讨论】:
-
Scrapy 日志在这里是相关的。是否发生了一些重定向?
标签: python web-scraping scrapy pycharm