Commit bd070d929998cc886a43a5fa536b3f89a3c293a8

  • avatar
  • arvind
  • Sat Mar 29 11:41:01 IST 2014
Generate access token based on app_secret and app_id.  Adding sampleConf.py,
this contains the keys for app_secret, app_id and username.
.gitignore
(1 / 0)
  
77lib/
88*.db
99*.pid
10conf.py
  
1# Copy to conf.py and edit the required fields.
2app_id = 'your facebook app id'
3app_secret = 'your facebook app secret'
4username = 'username to which the post has to be posted'
  
77from postScraper.items import PostscraperItem
88
99import facebook
10import conf
1011
1112
1213class SwaraSpider(CrawlSpider):
2222 xpath = Selector()
2323 loader = ItemLoader(item=PostscraperItem(), response=response)
2424
25 loader.add_xpath('content', '//div[@class="report"]/p/text()')
26 loader.add_xpath('audio',
27 '//div[@class="audiobox"]/object/@data',
28 re='(audio\/\d+\.mp3)')
29 loader.add_xpath('title', '//div[@class="report"]/h3/text()')
25 loader.add_xpath('content', '//div[@class="report"]/p/text()')
26 loader.add_xpath('audio',
27 '//div[@class="audiobox"]/object/@data',
28 re='(audio\/\d+\.mp3)')
29 loader.add_xpath('title', '//div[@class="report"]/h3/text()')
3030
31 content = [{item: loader.get_collected_values(item)[0]} for item in
32 loader.load_item()]
33
34 message = '{0}, {1}, http://cgnetswara.org/{2}'.format(
35 content[2]['title'].encode('utf8'), content[0]['content'].encode(
36 'utf8'),
37 content[1]['audio'].encode('utf8'))
38
39 graph = facebook.GraphAPI('CAAInjfaxO5kBAIGSm6cp7HQKpFDZAcRYIaGDswF5ZAZCpQZBQB2U5kZCyRLH2ShLZBkyGbJPDt8QzzB64WbrcZCuAo3rH5P7b1a59vTUK3m0CCZAGZCtDjwcTp7VwOlZCeCRmdcX9x6bsjNBrNgpwgRIcgbAI4cSnK2pHYlhOZBO5x5f4ZAsc5YGklj8xuxjg2Bu3ZB8ZD')
40 graph.put_object('me', 'feed', link=response.url,
41 description=content[0]['content'].encode('utf8'),
42 message="http://cgnetswara.org/"+content[1]['audio'])
31 content = [{item: loader.get_collected_values(item)[0]} for item in
32 loader.load_item()]
33 access_token = facebook.get_app_access_token(conf.app_id,
34 conf.app_secret)
35 graph = facebook.GraphAPI(access_token)
36 graph.put_object(conf.username, 'feed', link=response.url,
37 description=content[0]['content'].encode('utf8'),
38 message="http://cgnetswara.org/" +
39 content[1]['audio'])