INFO [2018-03-29 21:10:45] [test] Logged in successfully!
INFO [2018-03-29 21:13:45] [test] --> Users: 100
INFO [2018-03-29 21:13:45] [test] --> Username [1/100]
INFO [2018-03-29 21:10:45] [test] Logged in successfully!
ERROR [2018-03-29 21:12:13] [test] Unable to go to next profile post
ERROR [2018-03-29 21:13:29] [test] Unable to go to next profile post
This issue comes from the setting
session.set_dont_unfollow_active_users(True, posts=9)
.
NB: It works like a charm on windows.
Environment: Odroid C2
Distribution: Ubuntu 16.04.4 LTS
Architecture: aarch64
Pyhton version: Python 3.5.2
Hey @ValentinMebarki
open up util.py and add _one more line_ to raise the exception
occured
logger.error('Unable to go to next profile post')
raise ##you will add this new line
_it will help us to see the error details_
AND _meanwhile_, also, _try_ this change in the same file:
replace
browser.find_element_by_xpath(
"//a[@class='_3a693 coreSpriteRightPaginationArrow']"
"[text()='Next']").click()
with
next_elem = browser.find_element_by_xpath(
"//a[@class='_3a693 coreSpriteRightPaginationArrow']"
"[text()='Next']")
click_element(browser, next_elem)
It might be the issue of clicking, and
click_element
function sends clicks right from JS which may solve your issue...
Hey @uluQulu
I applied both changes.
Now there is a Traceback:
Traceback (most recent call last):
File "quickstart_complete.py", line 46, in <module>
session.set_dont_unfollow_active_users(True, posts=9)
File "/home/odroid/InstaPy/instapy/instapy.py", line 1787, in set_dont_unfollow_active_users
self.logger)
File "/home/odroid/InstaPy/instapy/util.py", line 156, in get_active_users
"//a[@class='_3a693 coreSpriteRightPaginationArrow']"
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 385, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 955, in find_element
'value': value})['value']
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //a[@class='_3a693 coreSpriteRightPaginationArrow'][text()='Next']
alright, @ValentinMebarki we now know that _it cannot locate the element given,._
now open up your profile and click on _one of your pictures_, then right click on the Next
button and click inspect
and screenshot the opened side in Elements tab of Chrome (_all just page elements there, no personal information :)_
we will make sure you have no any page element in other name (_than known to us_) by possible updates...
@uluQulu
Here it is.
screenshot
It seems to be the same class name targeted in the code.
Also something to point out is that there is no window opened when I launch the script.
@ValentinMebarki
In the capture you've posted, the Next
button is in german: Weiter
Does InstaPy also start in other language than english? (_if so, it will not find Next
button cos it will not really exist_)
I did not get the last sentence, no window opened where? are you using the headless mode?
@uluQulu
Ha ! That's the reason.
Indeed I'm in Germany and Instagram use my location to detect the language.
How do you think I can force Instagram to launch in default language (english) ?
My idea is to set my VPN with an US IP, but that's the backup solution.
@ValentinMebarki
switch_language
may help (_lots of people have had this issue and there are some turnouts, just search existing threads with that parameter_)
If you still can't solve it, ask me 馃憤 (also, changing IP adresses frequently is a real risk, forget about VPN, proxy stuff)
@uluQulu
I tried all the solutions proposed in #1359, #1280, #1279, #1062, #1046.
Nothing work so far.
What I did is playing with the switch_language boolean.
I need your help @uluQulu :-)
@ValentinMebarki
Can you describe briefly all you have tried? (_e.g. did you test with setting self.switch_language
= False right inside InstaPy class?_)
And what is the situation we are having here, your InstaPy loads webpages in _other language than engish_ (german)? (_how can you prove it, i mean, visible buttons are all in german? (e.g. Followers
, Like
, Comment
buttons) or only some buttons (e.g. non visible page elements like Weiter
in our last example?)_)
We need accurate information about the problem only then will find a portable solution 馃敩
@uluQulu
What I tried is
self.switch_language = True
,
then self.switch_language = False
from InstaPy class,
then session = InstaPy(switch_language=False)
,
then browser.get('https://www.instagram.com/?hl=en')
from login_util
I also reopened Instagram in chromium myself and all the visible and non visible buttons are in english, even the Next one.
Is there a way to check the language of those button when the webdriver selenium runs ?
NB: my quickstart is set with use_firefox=True
. So maybe it doesn't make sense to check with chromium.
@ValentinMebarki
Yes, if you use firefox you must check there, open up firefox browser and inspect that element again, see if it shows Weiter
or Next
and also have a look at other buttons' language
And also watch while InstaPy runs, see in what language it runs..
@uluQulu
I checked on Firefox.
While InstaPy run, there isn't any web pages that pops out opened (like in windows). So I can't see in what language it runs Instagram.
@ValentinMebarki
It makes sense cos InstaPy takes a referral from Google before visits IG which might be the source of the issue
But I don't know how you run InstaPy without a visual display since for firefox there is no headless
mode but maybe your device has no display, but okay
DO this to detect your IG language while running InstaPy:
_find_ and replace this line from util.py (_having considered you've still kept the changes from this comment_)
next_elem = browser.find_element_by_xpath(
"//a[@class='_3a693 coreSpriteRightPaginationArrow']"
"[text()='Next']")
with
next_elem = browser.find_element_by_xpath(
"//a[@class='_3a693 coreSpriteRightPaginationArrow']")
print("\n\nnext_elem is *{}*".format(next_elem.text))
sleep(1000)
and tell the output, _if it outputs Next
, it means InstaPy runs IG in english, likewise for other languages..._
@uluQulu
I never understood why there isn't any visual display. My device is connected with HDMI to a screen so normally I should see something. But that's an other issue :-)
I did the change. Here is the trace:
INFO [2018-03-31 20:29:20] [test] Session started - 2018-03-31 20:29:20
Cookie file not found, creating cookie...
INFO [2018-03-31 20:29:45] [test] Logged in successfully!
ERROR [2018-03-31 20:31:12] [test] Unable to go to next profile post
INFO [2018-03-31 20:31:13] [test] Session ended - 2018-03-31 20:31:13
INFO [2018-03-31 20:31:13] [test] --------------------
Traceback (most recent call last):
File "quickstart_complete.py", line 47, in <module>
session.set_dont_unfollow_active_users(True, posts=9)
File "/home/odroid/InstaPy/instapy/instapy.py", line 1787, in set_dont_unfollow_active_users
self.logger)
File "/home/odroid/InstaPy/instapy/util.py", line 156, in get_active_users
"//a[@class='_3a693 coreSpriteRightPaginationArrow']")
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 385, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 955, in find_element
'value': value})['value']
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //a[@class='_3a693 coreSpriteRightPaginationArrow']
I didn't find the output of the print().
@ValentinMebarki
I think for some reasons, selenium is not able to find that element at all, the language may not be the problem at all (_considering you've modified correctly_)
I am not good at web stuff, but there is something wrong with selenium finding, locating elements, either by some incompatibilities from updates or not, something is out of the place and needs to be clears, similar issue happened before (_see the changed lines at #1328_)
if finds something new I will help
@uluQulu
What is weird is that this issue ONLY happens when the setting session.set_dont_unfollow_active_users()
is set.
Have you considered this ?
@ValentinMebarki
It is the normal procedure needed for the set_dont_unfollow_active_users
feature in order to find active users by visiting your latest n
posts and there while clicking Next
it fails
For now, you should stop using that feature馃槕
@uluQulu
I understand. If you find something new, tell me.
"You're my only hope" @uluQulu
Hey @ValentinMebarki, try updating your selenium to the latest version and see if works
Hey @uluQulu, I have the last version of selenium: 3.11.0
I re-tried. I still doesn't work.
PS: I sent you a PM by mail
Quick question from @ValentinMebarki :
_I'm looking for a bot that can post at scheduled time on Instagram.
Do you know if this bot already exist as github project ?
If not, do you have some python code that can do this ?_
Short answer:
Yes!
Detailed answer:
It definetely is possible cos IG has an upload feature for browsers (_for mobile browsers only, yet_)
I am sure there are some decent github projects to do this, but I have not used any (_searching with the same keywords will bring a good list_)
For the quality of the uploads I try to upload pics from high-end devices (_mostly Galaxy S8_) and never approached browser uploads for that reason.
I have written some details in another issue of #1373 requesting the same feature
But I have said before, having this feature supported in InstaPy will be useful for many people (_might be!_) and it is very easy to implement (just needs some tests :/)
Currently I am not using IG (_just rarely_) and have a very busy graphic (_indeed!_) but I would help you with it if adds up some bounty :P (_if you wanna implement it yourselves, I can tell the guideline, too_)
That was for the upload(s) capability, but for the scheduling an upload, well I have never used built-in python schedulers and have no expereince with them, but I am sure it will be very easy to do it, too!
I got really busy time, sorry for late reply, cheers buddy!
@uluQulu Thanks for your reply !
Currently, i'm creating 3 posts a day on my IG account. To do that, I upload via browser with the responsive feature of chrome dev tool. The only time you need to use a real mobile phone is to post video. Regularity is the key in content marketing. The issue is sometimes you can't post when you want.
Thats why we need a feature - personnaly I think it's a must-have -
to post at scheduled time. And even if the use of python scheduler is hard, a simple cron job is ok.
I searched for some github projects to do that but i didn't find anything popular.
I tried on my own to develop a puppeteer script with NodeJS to post a picture. It worked until you have to browse your computer directory to upload any file. Puppeter doesn't give the possibility to interact with the browsing window.
I estimate the task at 2-3 man/days for a python skilled dev.
@CharlesCCC have you more time to think about that today ? :-)
Same for busy time here :-)
@ValentinMebarki Yea, this is one of the thing that is keep hunting me at a time, I have basically the same need as you do. schedule post everyday for my account. but as everybody else(aka. @uluQulu ) I'm currently still doing a day job and also very busy with other projects, I currently don't have a schedule for it yet. but I will definitely keep you posted when I have the time for it. (you might want to keep track of the #1373 instead of this one, consider that is the main thread for this feature).
@CharlesCCC Right. I'll keep track of #1373 then.
Thanks both for your help.
Alright @ValentinMebarki, I will help you to achieve it but you must help me to test it 馃槈
Okay @uluQulu
I go on holiday for one month in 2 weeks.
That's why I began working on Post Upload Automation.
First issue: use chromedriver with mobile viewport
I tried what you suggested in #1373, adding this to instapy.py
mobile_emulation = { "deviceName": "BlackBerry Z30" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
But there is no upload button appearing.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this problem still occurs, please open a new issue
Most helpful comment
Hey @uluQulu
I applied both changes.
Now there is a Traceback: