| |   |
7 | 7 | from postScraper.items import PostscraperItem |
8 | 8 | |
9 | 9 | import facebook |
import conf |
10 | 11 | |
11 | 12 | |
12 | 13 | class SwaraSpider(CrawlSpider): |
… | … | |
22 | 22 | xpath = Selector() |
23 | 23 | loader = ItemLoader(item=PostscraperItem(), response=response) |
24 | 24 | |
loader.add_xpath('content', '//div[@class="report"]/p/text()') |
loader.add_xpath('audio', |
'//div[@class="audiobox"]/object/@data', |
re='(audio\/\d+\.mp3)') |
loader.add_xpath('title', '//div[@class="report"]/h3/text()') |
loader.add_xpath('content', '//div[@class="report"]/p/text()') |
loader.add_xpath('audio', |
'//div[@class="audiobox"]/object/@data', |
re='(audio\/\d+\.mp3)') |
loader.add_xpath('title', '//div[@class="report"]/h3/text()') |
30 | 30 | |
content = [{item: loader.get_collected_values(item)[0]} for item in |
loader.load_item()] |
|
message = '{0}, {1}, http://cgnetswara.org/{2}'.format( |
content[2]['title'].encode('utf8'), content[0]['content'].encode( |
'utf8'), |
content[1]['audio'].encode('utf8')) |
|
graph = facebook.GraphAPI('CAAInjfaxO5kBAIGSm6cp7HQKpFDZAcRYIaGDswF5ZAZCpQZBQB2U5kZCyRLH2ShLZBkyGbJPDt8QzzB64WbrcZCuAo3rH5P7b1a59vTUK3m0CCZAGZCtDjwcTp7VwOlZCeCRmdcX9x6bsjNBrNgpwgRIcgbAI4cSnK2pHYlhOZBO5x5f4ZAsc5YGklj8xuxjg2Bu3ZB8ZD') |
graph.put_object('me', 'feed', link=response.url, |
description=content[0]['content'].encode('utf8'), |
message="http://cgnetswara.org/"+content[1]['audio']) |
content = [{item: loader.get_collected_values(item)[0]} for item in |
loader.load_item()] |
access_token = facebook.get_app_access_token(conf.app_id, |
conf.app_secret) |
graph = facebook.GraphAPI(access_token) |
graph.put_object(conf.username, 'feed', link=response.url, |
description=content[0]['content'].encode('utf8'), |
message="http://cgnetswara.org/" + |
content[1]['audio']) |