Hi I want to only scrape pages whose lastmod
date is newer than specific date.
For example: Only scrape the url if lastmod
is 14/9/2017 or newer.
I use this code to scrape all the pages but I can't restrict it based on lastmod
date:
import requests
from scrapy.spiders import SitemapSpider
from urllib.parse import urljoin
class MySpider(SitemapSpider):
name = 'sitemap_spider'
robots_url = 'http://www.example.org/robots.txt'
sitemap_urls = [robots_url]
sitemap_follow = ['products-eg-ar']
def parse(self, response):
print(response.url)
This is my robots.txt
sitemap: /sitemap-products-eg-ar-index-1-local.xml
the sitemap-products-eg-ar-index-1-local.xml
contains:
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>/sitemap-products-eg-ar-1.xml</loc>
</sitemap>
<sitemap>
<loc>/sitemaps/sitemap-products-eg-ar-2.xml</loc>
</sitemap>
</sitemapindex>
and sitemap-products-eg-ar-2.xml
contains:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>/product-8112041/i/</loc>
<priority>0.8</priority>
<lastmod>2017-06-17</lastmod>
<changefreq>daily</changefreq>
</url>
</urset>