Hallo Ich möchte nur Seiten schaben, deren lastmod
Datum neuer ist als ein bestimmtes Datum.Scrapfen URLs, wenn neuer als lastmod Datum -Scrapy
Zum Beispiel: Nur die URL abkratzen, wenn lastmod
14/9/2017 oder neuer ist.
ich diesen Code verwenden, um alle Seiten zu kratzen, aber ich kann es nicht auf lastmod
Datum beschränken:
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)
Dies ist mein robots.txt
sitemap: /sitemap-products-eg-ar-index-1-local.xml
die sitemap-products-eg-ar-index-1-local.xml
enthält:
<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>
und sitemap-products-eg-ar-2.xml
enthält:
<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>