|
@@ -1,6 +1,7 @@
|
1
|
1
|
from urllib import quote
|
2
|
2
|
from lxml import html
|
3
|
3
|
from urlparse import urljoin
|
|
4
|
+from cgi import escape
|
4
|
5
|
|
5
|
6
|
base_url = 'http://stackoverflow.com/'
|
6
|
7
|
search_url = base_url+'search?q='
|
|
@@ -20,6 +21,6 @@ def response(resp):
|
20
|
21
|
link = result.xpath('.//div[@class="result-link"]//a')[0]
|
21
|
22
|
url = urljoin(base_url, link.attrib.get('href'))
|
22
|
23
|
title = ' '.join(link.xpath('.//text()'))
|
23
|
|
- content = ' '.join(result.xpath('.//div[@class="excerpt"]//text()'))
|
|
24
|
+ content = escape(' '.join(result.xpath('.//div[@class="excerpt"]//text()')))
|
24
|
25
|
results.append({'url': url, 'title': title, 'content': content})
|
25
|
26
|
return results
|