Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. root@insta-bot:~/instagram/instagrambot/VintageCars/JS Scripts# nodejs upld_Cars .js
  2. /root/instagram/instagrambot/VintageCars/JS Scripts/upld_Cars.js:8
  3. let data = '';
  4. ^^^
  5.  
  6. SyntaxError: Block-scoped declarations (let, const, function, class) not yet sup ported outside strict mode
  7. at exports.runInThisContext (vm.js:53:16)
  8. at Module._compile (module.js:374:25)
  9. at Object.Module._extensions..js (module.js:417:10)
  10. at Module.load (module.js:344:32)
  11. at Function.Module._load (module.js:301:12)
  12. at Function.Module.runMain (module.js:442:10)
  13. at startup (node.js:136:18)
  14. at node.js:966:3
  15.  
  16. //Download
  17. const https = require('https');
  18. const download = require('image-downloader')
  19.  
  20. var search ='sexy-car'
  21. https.get('NOTREALSEARCHCRITERIA, (resp) => {
  22. let data = '';
  23.  
  24. // A chunk of data has been recieved.
  25. resp.on('data', (chunk) => {
  26. data += chunk;
  27. });
  28.  
  29. // The whole response has been received. Print out the result.
  30.  
  31. resp.on('end', () => {
  32. photoUrl = JSON.parse(data).urls.custom;
  33. console.log(photoUrl);
  34. // Download to a directory and save with the original filename
  35. const options = {
  36. url: photoUrl,
  37. dest: 'C:/Users/USER/Desktop/instagrambot/VintageCars/unsplash_Vintage_Car_dwnld/image.jpg' // Save to /path/to/dest/image.jpg
  38. }
  39.  
  40. download.image(options)
  41. .then(({ filename, image }) => {
  42. console.log('File saved to', filename)
  43. }).catch((err) => {
  44. throw err
  45. })
  46. });
  47.  
  48. }).on("error", (err) => {
  49. console.log("Error: " + err.message);
  50. });
  51.  
  52.  
  53. // Upload
  54. var Client = require('instagram-private-api').V1;
  55. var device = new Client.Device('FAKEDEVICE');
  56. var storage = new Client.CookieFileStorage(__dirname + '/cookies/carVintagePage.json');
  57.  
  58. var username = 'NOTREALUSERNAME';
  59. var pass = 'NOTREALPASS'
  60.  
  61. var Approved_Hashtags = ['#Beautiful ', '#Vintage ', '#Car ', '#Carstagram ', '#OnlyAutomobiles ',
  62. '#OldStyle ' , '#Classic ', '#OldCars ', '#OldAutos ', '#ClassicCars ',
  63. '#CarPorn ', '#VintageCar ', '#Stunning ', '#Amazing '];
  64.  
  65. var caption = getCaption(Approved_Hashtags);
  66.  
  67. var pathOrStream = 'C:/Users/USER/Desktop/instagrambot/VintageCars/unsplash_Vintage_Car_dwnld/image.jpg';
  68.  
  69. Client.Session.create(device, storage, username, pass)
  70. .then(function(session){
  71. return [Client.Upload.photo(session, pathOrStream), session]
  72. })
  73. .spread(function(upload, session) {
  74. return Client.Media.configurePhoto(session, upload.params.uploadId, caption)
  75. })
  76. .then(function(medium) {
  77. console.log(medium)
  78. })
  79.  
  80. //////////////////////function////////////////////////////////
  81.  
  82. function getCaption(arr) {
  83. n = Math.floor(Math.random() * 7) + 3
  84. var result = new Array(n),
  85. len = arr.length,
  86. taken = new Array(len);
  87. while (n--) {
  88. var x = Math.floor(Math.random() * len);
  89. result[n] = arr[x in taken ? taken[x] : x];
  90. taken[x] = --len;
  91. }
  92.  
  93. var caption = '';
  94. for(var tag of result)
  95. caption+= tag;
  96.  
  97. return caption;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement