1
嗨我只想刮掉其日期比特定日期更新的页面。如果比上次修改日期更新,刮去网址-Scrapy
例如:如果lastmod
是2017/14/9或更新版本,只能刮掉网址。
我使用此代码来凑所有的页面,但我不能限制它的基础上lastmod
日期:
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)
这是我robots.txt
sitemap: /sitemap-products-eg-ar-index-1-local.xml
的sitemap-products-eg-ar-index-1-local.xml
包含:
<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>
和sitemap-products-eg-ar-2.xml
包含:
<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>