Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

add __hash__ method to Link object to be compatible with the __eq__ method

Shane Evansc5351d2f4882
diff --git a/scrapy/link.py b/scrapy/link.py
index ddae07823..371a987cb 100644
--- a/scrapy/link.py
+++ b/scrapy/link.py
@@ -18,6 +18,9 @@ class Link(object):
def __eq__(self, other):
return self.url == other.url and self.text == other.text
+
+ def __hash__(self):
+ return hash(self.url) ^ hash(self.text)
def __repr__(self):
return '<Link url=%r text=%r >' % (self.url, self.text)