├── requirements.txt ├── README.md └── example.py /requirements.txt: -------------------------------------------------------------------------------- 1 | instagram-scraper 2 | instapy-cli 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Instagram-scraper-with-autopost 2 | 3 | This script scrapes images from users and then repost them under your Instagram accounts with your own tags. 4 | 5 | To install script: 6 | 7 | git clone https://github.com/reliefs/Instagram-scraper-with-autopost.git 8 | 9 | cd Instagram-scraper-with-autopost 10 | 11 | sudo pip install -r requirements.txt 12 | 13 | open example.py change: change inside insta_profiles to users you wanna scrape and then change "yourusername" and "yourpassword" 14 | 15 | Run: python example.py 16 | -------------------------------------------------------------------------------- /example.py: -------------------------------------------------------------------------------- 1 | import time 2 | import instagram_scraper as insta 3 | import json 4 | from subprocess import call 5 | 6 | insta_profiles = ['billgates', 'elonmusk'] 7 | number_last_photos = 3 8 | 9 | def scraper(): 10 | #call('instagram-scraper ' + insta_profiles + ' -m ' + number_last_photos + ' -u 0 -p 0 -t none --media-metadata', shell=True) 11 | imgScraper = insta.InstagramScraper(usernames=[insta_profiles[x]], login_user="yourusername", login_pass="yourpassword", maximum=number_last_photos, media_metadata=True, latest=True,media_types=['image']) 12 | imgScraper.scrape() 13 | # Take last json image data and post in instagram images, tags and decription 14 | with open(insta_profiles[x] + '/' + insta_profiles[x] + '.json', 'r') as j: 15 | json_data = json.load(j) 16 | newstr = (json_data[0]["display_url"]) 17 | imgUrl = newstr.split('?')[0].split('/')[-1] 18 | imgTags = (json_data[0]["tags"]) 19 | # imgDescription = (json_data[0]["description"]) 20 | #Execute Instagram users with instapy. Excecute list insta_profiles 21 | call('instapy -u yourusername -p yourpassword -f ./' + insta_profiles[x] + '/' + imgUrl +' -t "#model #models #Modeling #modelo #modellife #modelling #modelagency #Modelos #modelphotography #modelsearch #ModelStatus #modelingagency #modelfitness #ModelsWanted #modelshoot #modella #modelmanagement #modelscout #modeltest #modelindonesia #modele #modelife #modelmayhem #modelgirl #modell #modelslife #modelkids #modelcall #modelpose #ModelBehavior"', shell=True) 22 | time.sleep(5) 23 | # Account number 2 24 | call('instapy -u yourusername -p yourpassword -f ./' + insta_profiles[x] + '/' + imgUrl +' -t "#model #models #Modeling #modelo #modellife #modelling #modelagency #Modelos #modelphotography #modelsearch #ModelStatus #modelingagency #modelfitness #ModelsWanted #modelshoot #modella #modelmanagement #modelscout #modeltest #modelindonesia #modele #modelife #modelmayhem #modelgirl #modell #modelslife #modelkids #modelcall #modelpose #ModelBehavior"', shell=True) 25 | print(imgUrl) 26 | 27 | print ("scraped " + str(number_last_photos) + " from " + insta_profiles[x]) 28 | def main(): 29 | scraper() 30 | 31 | for x in range(len(insta_profiles)): 32 | main() 33 | time.sleep(1000) 34 | 35 | --------------------------------------------------------------------------------