a few months back, I started my search for some easy way to write a script that could alert me when a keyword is posted in a thread from a forum section.
So, my research leads me to the python module scrapy, that I was happy to try because I already knew some python.
I tried but the result I got was not satisfactory enough.
let's explain what i wanted:
I am interested in retrieving the threads from the forum classified section, check if a new message has been posted and send me a message if a new thread with a specific word appears in the title.
Here is my code, ntspider.py:
from scrapy.http import Request
class MySpider(BaseSpider):
name = "LP195xSearch"
allowed_domains = ["www.mylespaul.com"]
start_urls = ["http://www.mylespaul.com/forums/member-classifieds/"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
titles = hxs.select('//a[contains(@id,"thread_title")]/text()').extract()
t =[]
for title in titles:
t.append(title)
item = LP195xSearchItem()
item["title"] = title
yield item
for i in xrange(len(t)):
print repr(str(t[i])).center(20)
This is only retrieving and printing the threads titles, and now I want to allert me if onw keywork is found.
Any help would be very very welcome.