instapy / instapy Goto Github PK
View Code? Open in Web Editor NEW๐ท Instagram Bot - Tool for automated Instagram interactions
License: GNU General Public License v3.0
๐ท Instagram Bot - Tool for automated Instagram interactions
License: GNU General Public License v3.0
In the function like_image I faced error while fetching element from xpath
//article/div[2]/section[1]/a[1]/span[1]
and after small debugging in instagram's image view DOM I updated the xpath //article/div[2]/section[2]/a[1]/span[1]
Same in the function check_link
Changed the xpath from //article/div[2]/div[1]/ul[1]/li[1]
to //article/div[2]/ul[1]/li[1]
I'm new to Github so I don't know how to submit a fix but leaving this here so that people can refer the issue here :)
Also, guide me with the right method to submit a fix if any.
Traceback (most recent call last):
File "quickstart.py", line 7, in
.like_by_tags(['#jainism', '#jain', '#jainsmo'], amount=100)
File "C:\Users\user\Documents\insta\InstaPy\instapy\instapy.py", line 224, in like_by_tags
self.ignore_if_contains, self.username)
File "C:\Users\user\Documents\insta\InstaPy\instapy\like_util.py", line 67, in check_link
print('Description: ' + image_text)
File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u0131' in position
44: character maps to
Thought about dockerizing it ? Would be way easier to deploy.
InstagramApi is public and is also restricted for each Api. But the implementation speed should be faster than webDriver
Hi! Looks like a fun project to work on!
Just followed your steps - try to setup using setup.py. Kept getting permission denied and such:
Checking .pth file support in /Library/Python/2.7/site-packages/
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: /Library/Python/2.7/site-packages/test-easy-install-4896.pth
The installation directory you specified (via --install-dir, --prefix, or the distutils default setting)
was:
/Library/Python/2.7/site-packages/
Then figured this needs to be run via Python 3.
So ran the same command as python3 setup.py install
So was wondering if we need a better guide or need a good dependency management?
(Saw someone has an open PR for Docker +1 for that!)
PS - sorry if this is lame, been a Java developer all of my life except a couple of projects ๐
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 119: ordinal not in range(128) for some links
--> Image Liked!
Traceback (most recent call last):
File "./quickstart.py", line 19, in <module>
.like_by_tags(['#dog', '#messi', '#cr7', 'top'], amount=100) \
File "/home/synod/AT/cronos/InstaPy/instapy/instapy.py", line 271, in like_by_tags
print('Invalid Page: ' + str(err))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 119: ordinal not in range(128)
I am getting this error even after replacing the file in assets. My OS is windows 10 and chrome is updated to latest version.
Traceback (most recent call last):
File "quickstart.py", line 1, in <module>
from instapy import InstaPy
File "C:\Users\rahul\Desktop\InstaPy\instapy\__init__.py", line 1, in <module>
from .instapy import InstaPy
File "C:\Users\rahul\Desktop\InstaPy\instapy\instapy.py", line 11, in <module>
from .clarifai_util import check_image
File "C:\Users\rahul\Desktop\InstaPy\instapy\clarifai_util.py", line 3, in <module>
from clarifai.client import ClarifaiApi
File "C:\Users\rahul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\clarifai-2.0.20-py3.6.egg\clarifai\client\__init__.py", line 5, in <module>
File "C:\Users\rahul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\clarifai-2.0.20-py3.6.egg\clarifai\client\client.py", line 4, in <module>
ModuleNotFoundError: No module named 'past'
Alright I worked my way through getting this to work as far as I could, and this is just beyond my Python ability.
Running this script:
#########################################
dont_like = ['food', 'girl', 'hot']
ignore_words = ['pizza']
friend_list = ['friend1', 'friend2', 'friend3']
InstaPy(username='xxxx', password='xxxx')
.login()
.set_do_comment(True, percentage=0)
.set_comments(['Cool!', 'Awesome!', 'Nice!'])
.set_dont_include(['friends here'])
.set_dont_like(dont_like)
.set_do_follow(True, percentage=0)
.unfollow_users(amount=100)
.set_ignore_if_contains(ignore_words)
.like_by_tags(['fit', '#muaythai'], amount=0)
.set_use_clarifai(enabled=False)
.end()
##########################################
getting this error:
##########################################
C:\Users\Matt>C:\Users\Matt\Desktop\InstaPy-master\quickstart.py
Traceback (most recent call last):
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in init
restore_signals, start_new_session)
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Matt\Desktop\InstaPy-master\quickstart.py", line 10, in
InstaPy(username='xxxx', password='xxxx')
File "C:\Users\Matt\Desktop\InstaPy-master\instapy\instapy.py", line 31, in init
self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in init
self.service.start()
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Exception ignored in: <bound method Service.del of <selenium.webdriver.chrome.service.Service object at 0x0000023F33295FD0>>
Traceback (most recent call last):
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 173, in del
self.stop()
File "C:\Users\Matt\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 145, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
@timgrossmann Thanks for the scripts! I have the whole server with the scripts running but the last part of automating is difficult. Can you let me know at what time you run the script? and using cronjob or screen?
Can you share the command and where should I add it?
Here's my cronjob file contents:
SHELL=/bin/bash
HOME=/
[email protected]
*/30 * * * * source /var/venv/bin/activate && python /var/InstaPy/quickstart.py >> /var/InstaPy/logs/cron.log
I did got an cron.log file created but it was empty don't know what's wrong. please help.
As the Chromedriver that comes with this package is for linux - this won't run if you are trying to run it on windows. I replaced the chrome driver in the assets with the windows version - extracted of course.
https://chromedriver.storage.googleapis.com/2.29/chromedriver_win32.zip
$ python quickstart.py Traceback (most recent call last): File "quickstart.py", line 10, in <module> InstaPy(username='XXX', password='XXX')\ File "/home/giebeka/InstaPy/instapy/instapy.py", line 34, in __init__ self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options) File "/usr/lib/python2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__ self.service.start() File "/usr/lib/python2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/common/service.py", line 64, in start stdout=self.log_file, stderr=self.log_file) File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 8] Exec format error
The like function isn't language independent.
Hi,
first of all GREAT work!
Liked your reply to the first "issue" :)
When executing the script it all works till it loads the first hashtag and tries to like some.
I see this in terminal:
for _ in range(new_needed): # add images x * 12
TypeError: range() integer end argument expected, got float.
What do I need to change?
Thanks!
M
I get this error when the app is running and tries to leave a comment:
[3/100]
Invalid Page: Message: no such element: Unable to locate element: {"method":"class name","selector":"_nk46a"}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.25.426935 (8***),platform=Mac OS X 10.12.3 x86_64)
Likes and engagement are digital currency and you are devaluing them. You should add a disclaimer that users are risking being banned from the platform.
It could search through the tags and look at the posted location (if given) to determine if it's near your location
Could look somewhat like this:
.set_only_locals(True) #default False
.set_locals(['Stuttgart', 'Ludwigsburg', 'Bad Canstatt'])
.like_by_location([...])
Hi, I'm trying to use the example before starting to change anything. I change my user and pass and downloaded the chromedriver and put it in the assets folder. I am using Mac OSX 10.11.5.
I am getting this error
python quickstart.py
Logged in successfully!
Traceback (most recent call last):
File "quickstart.py", line 6, in <module>
session.login()
File "/Users/emiliomarin/Desktop/Fotos/Instagram/InstaPy-master/instapy/instapy.py", line 83, in login
log_follower_num(self.browser, self.username)
File "/Users/emiliomarin/Desktop/Fotos/Instagram/InstaPy-master/instapy/print_log_writer.py", line 10, in log_follower_num
('//a[@href="/' + username.lower() + '/followers/"]')
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 293, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 752, in find_element
'value': value})['value']
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@href="/havetstest/followers/"]"}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.11.5 x86_64)
.set_do_message(True, percentage=10)\
.set_direct_messages([])\
I would try your script on my system but i have one problem.
I have osx 10.11 and i have install chromedriver with brew.
brew install chromedriver
This install version 2.29 under /usr/local/Cellar/chromedriver/2.29.
In this path, the folder bin contain a ./chromedriver file that i have put in the assets folder.
But when i start your example script with:
python quickstart.py
the system return this error:
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service ./assets/chromedriver
I setup username and password trough default parameters.
I tried to download chromedriver from https://sites.google.com/a/chromium.org/chromedriver/downloads,
but the error is the same.
This is the traceback of the error
File "quickstart.py", line 10, in <module>
InstaPy(username='username', password='mypassword')\
File "/Users/davide/Workspace SSD/GitHub Repo/InstaPy/instapy/instapy.py", line 31, in __init__
self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
File "/Library/Python/2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/Library/Python/2.7/site-packages/selenium/webdriver/common/service.py", line 92, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service ./assets/chromedriver
What i can do?
thanks!
I get this error and the script crashes after about 5-10 likes:
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <span class="_soakw coreSprite...HeartOpen">Like</span> is not clickable at point (445, 463). Other element would receive the click: <div class="_mghjk">...</div>
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-72-generic x86_64)
method check_image_for that used in examples didn't defined in InstaPy Class Members and problem in run example
I have the following log message:
Invalid Page: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//article/div[2]/div[1]/ul[1]/li[1]"}
Every time a page is loaded.
I have a small screen, maybe the "phone version" of the page is loaded?
Any idea?
C:\Users\Matt>python C:\Users\Matt\Desktop\InstaPy-master\quickstart.py
Traceback (most recent call last):
File "C:\Users\Matt\Desktop\InstaPy-master\quickstart.py", line 1, in
from instapy import InstaPy
File "C:\Users\Matt\Desktop\InstaPy-master\instapy_init_.py", line 1, in
from .instapy import InstaPy
File "C:\Users\Matt\Desktop\InstaPy-master\instapy\instapy.py", line 6, in
from pyvirtualdisplay import Display
ModuleNotFoundError: No module named 'pyvirtualdisplay'
Getting this error and, indeed, I can't find any pyvirtualdisplay file. Wut do?
Could look somewhat like this:
.set_upper_follower_count(1000) # default is INT Max
pip install instapy
instead of downloading the repoThe problem is, that it could be viewed as spammy if you follow/unfollow the same account multiple times
session.set_do_follow(enabled=True, percentage=10, times=2) #default times is 1
I'm trying to install a script, but I'm a total noob
So please help
I downloaded this script and alos chromediver and python 3.6
and i dont know what to do lol.. i installed python where i should type "cd InstaPy
pip install ."
lol sorry for stupid question...
Traceback (most recent call last):
File "newunder.py", line 8, in <module>
session = InstaPy(username='', password='')
File "/home/brunocechet/git-projects/InstaPy/instapy/instapy.py", line 33, in __init__
self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error```
I can't figure out :/
@timgrossmann pls mention somewhere in readme.md that changing comments percentage to 100 could lead to a temporary ban and account password reset by Instagram. I didn't knew this and suffered. lol
๐๐ป Emoji support for comments would be great.
Right now it's breaking because of the send_key()
event which does not recognize the emojis and break.
It might be useful to comment only on Posts with a certain language.
So you could comment in german on german posts or skip posts in a language you donโt speak at all (turkish community in big cities).
Iโm not sure how to implement this. As far as I know, Instagram isnโt providing language tags for their posts, so weโd need to implement language detection in our scripts ourselves.
Since Instagram has both videos and photos now, it would be nice to filter for media types. Otherwise, comments like โGreat photo!โ might seem akward when posted on videos.
Using the tester.py provided in instaPy-master folder and no matter what tags I'm looking at, I'm getting following error output:
$ python tester.py
It is recommended to install PIL/Pillow with the desired image format support so that image resizing to the correct dimesions will be handled for you. If using pip, try "pip install Pillow"
Logged in successfully!
Tag [1/1]
--> veganfoodshare
Too few images, aborting
Session ended
-------------
Am I missing something?
Would it be nice if, we add a feature which will follow the people suggested by Instagram in SUGGESTIONS FOR YOU box. Also we can like their updates.
This will increase the chances of following back by that person.
I have tried both ways of installation packages but every single time I am getting the same error.
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 357, in _handle_tasks
debug('task handler got sentinel')
TypeError: 'NoneType' object is not callable
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 330, in _handle_workers
debug('worker handler exiting')
TypeError: 'NoneType' object is not callable
error: Setup script exited with error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
There are some deleted posts/ dead links when going through the to be liked pictures. Right now the process crashes when one of these pages shows up.
Following an user just after one like seems a bit implausible.
In my opinion it would be good to like 2 or 3 photos of an user before following them. This way our bot behaves and looks more like a real user and should raise engagement rates.
So the new strategy would be like:
For comment automation it could be interesting to support Spintax in order to vary the comment text.
https://github.com/AceLewis/spintax might be a good candidate.
passing different values
It would be awesome to be able to set the comments like this:
.set_comments(['Cool! ๐', 'Awesome ๐', 'Nice! ๐', '๐'])\
First, a big thanks for your efforts and for writing your media blog post!
Since Iโve never worked with Python, Iโm not really sure what is necessary to get started with InstaPy.
I cloned your repository to uberspace, modified quickstart.py according to my aims and executed via SSH python setup.py install
. Do I need to do anything else/different? For me the script doesnโt seem to work since my following accounts stays the same.
Also, what would be needed to do when I alter settings in quickstart.py? Will InstaPy automatically run with the new settings or is there anything to do to restart InstaPy?
Thanks in advance!
Kind regards
Tibor
Please add requirements list for ease, thankyou
Maybe you should allow people to fetch platform specific chromedrivers (from chrome sites) instead of distributing one. I had an issue with Exec format being wrong ?
Traceback (most recent call last):
File "./quickstart.py", line 12, in <module>
InstaPy(username='test', password='test')\
File "/home/synod/AT/cronos/InstaPy/instapy/instapy.py", line 31, in __init__
self.browser = webdriver.Chrome('./assets/chromedriver', chrome_options=chrome_options)
File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
I guess this will be easy with the package being on PyPI
I have two accounts. With one of them, it worked and I saw auto likes. When I try the other account, Invalid page message is displayed. Both accounts are public and don't have special characters.
Invalid Page: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//article/div[2]/div[1]/ul[1]/li[1]"} (Session info: chrome=57.0.2987.133) (Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.4 x86_64)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.