Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@insta-bot:~/instagram/instagrambot/VintageCars/JS Scripts# nodejs upld_Cars .js
- /root/instagram/instagrambot/VintageCars/JS Scripts/upld_Cars.js:8
- let data = '';
- ^^^
- SyntaxError: Block-scoped declarations (let, const, function, class) not yet sup ported outside strict mode
- at exports.runInThisContext (vm.js:53:16)
- at Module._compile (module.js:374:25)
- at Object.Module._extensions..js (module.js:417:10)
- at Module.load (module.js:344:32)
- at Function.Module._load (module.js:301:12)
- at Function.Module.runMain (module.js:442:10)
- at startup (node.js:136:18)
- at node.js:966:3
- //Download
- const https = require('https');
- const download = require('image-downloader')
- var search ='sexy-car'
- https.get('NOTREALSEARCHCRITERIA, (resp) => {
- let data = '';
- // A chunk of data has been recieved.
- resp.on('data', (chunk) => {
- data += chunk;
- });
- // The whole response has been received. Print out the result.
- resp.on('end', () => {
- photoUrl = JSON.parse(data).urls.custom;
- console.log(photoUrl);
- // Download to a directory and save with the original filename
- const options = {
- url: photoUrl,
- dest: 'C:/Users/USER/Desktop/instagrambot/VintageCars/unsplash_Vintage_Car_dwnld/image.jpg' // Save to /path/to/dest/image.jpg
- }
- download.image(options)
- .then(({ filename, image }) => {
- console.log('File saved to', filename)
- }).catch((err) => {
- throw err
- })
- });
- }).on("error", (err) => {
- console.log("Error: " + err.message);
- });
- // Upload
- var Client = require('instagram-private-api').V1;
- var device = new Client.Device('FAKEDEVICE');
- var storage = new Client.CookieFileStorage(__dirname + '/cookies/carVintagePage.json');
- var username = 'NOTREALUSERNAME';
- var pass = 'NOTREALPASS'
- var Approved_Hashtags = ['#Beautiful ', '#Vintage ', '#Car ', '#Carstagram ', '#OnlyAutomobiles ',
- '#OldStyle ' , '#Classic ', '#OldCars ', '#OldAutos ', '#ClassicCars ',
- '#CarPorn ', '#VintageCar ', '#Stunning ', '#Amazing '];
- var caption = getCaption(Approved_Hashtags);
- var pathOrStream = 'C:/Users/USER/Desktop/instagrambot/VintageCars/unsplash_Vintage_Car_dwnld/image.jpg';
- Client.Session.create(device, storage, username, pass)
- .then(function(session){
- return [Client.Upload.photo(session, pathOrStream), session]
- })
- .spread(function(upload, session) {
- return Client.Media.configurePhoto(session, upload.params.uploadId, caption)
- })
- .then(function(medium) {
- console.log(medium)
- })
- //////////////////////function////////////////////////////////
- function getCaption(arr) {
- n = Math.floor(Math.random() * 7) + 3
- var result = new Array(n),
- len = arr.length,
- taken = new Array(len);
- while (n--) {
- var x = Math.floor(Math.random() * len);
- result[n] = arr[x in taken ? taken[x] : x];
- taken[x] = --len;
- }
- var caption = '';
- for(var tag of result)
- caption+= tag;
- return caption;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement