New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InstaPy 0.7.0 #4279
Comments
Thanks for starting this up @breuerfelix ! Firstly, I like the idea of APIs with singular functions; less hassle to manage and way simpler to implement new features on top. Also really stoked to see your thinking on how to handle extensions - it makes a lot of sense! As long as there's a defined standard around the available hooks it should be fine. I have a few things to add... Given the recent issue with XPaths, it would absolutely make sense to maintain them in a constants file separate to the functions so they can be updated in a single place hopefully minimising some risk to the code. I've also been thinking about the best way to implement some kind of analytics into InstaPy to measure activity and be able to tie it to conversions like new followers. Either using local storage or pushing to your own server via an exposed endpoint. Lastly - this is part refactor and part new feature - but it I feel it would make sense to build a web interface that allows the visualisation of the analytics but also allows for dynamic configuration of interactions. If you want to change who you're interacting with or what those interactions should be on the fly, this should be possible. I'm pretty certain this will be a massively useful feature for proper campaign management. |
Really great idea! @converge had the idea to provide them as a cdn on each start of the bot with https://www.jsdelivr.com :) so people don't even have to update their bot for the updates xpaths, this just happens on its own !
Thats what I already built ! it's only available for Gui backers at the moment but will be released fully open source soon, once its more stable :) if you are interested in developing this gui you can chat me on discord ! would be really great :) |
Since XPaths are a static Resource I would suggest using GitHub as a "database". We can access it via HTTP, everybody is able to see it's source, anytime, everybody is able to make issues, pull request, etc, to enhance the source or fix it. |
I decided it would be good to test part of this concept out, so I've added a PR (https://github.com/timgrossmann/InstaPy/pull/4301) with this implemented using a local JSON file created by a compiler. I've kept the XPath reader as a separate utility so it can easily be modified to pull a remote file - we'd just have to consider the security implications of whichever approach the project ends up implementing. For the time being, just updating the JSON file to the latest version would be enough. There are maybe some more efficient ways of doing it, but some not without refactoring all of the code anyway. Keen to take on any feedback and I'll keep updating it. |
Hi Folks, first off: I love InstaPy and is finally a reason to really dive into Python a bit more. (and yes I'm a python noob but have used many other languages before so I pretend to be a fast learner). Reading there are thoughts to consider a rework it may the right time to explain my struggles. Either the functionality is missing, it's there but badly described or I'm an idiot. For later one: please bear with me and simply ignore :) I'm planning to interact with InstaPy via Telegram. Doing a quickstart.py and interacting with my telegram library works but some issues pop up. Namely:
And general
|
Coming back to what you PRed a while ago 😉 |
On the custom logging front, it would be cool if you exposed an easier way to configure logging. I usually just override the logger with my own, using something like this:
It'd be pretty cool if you could maybe expose a better API for doing this in a canonical way, or make it easier to discover how to override the logger in documentation. |
@samrap I was thinking about doing something similar where you can set your logging endpoint in the config to either a URI or a function. Does that sound like what you had in mind? I want to spend some time digging through the code again soon and propose a measurement strategy that we can hopefully move forward with. |
@analyticsdept I was imagining exposing a hook to easily configure log handlers, that way the user has full control of what the logging does. For example, you could attach a stdout handler that emits everything, a JSON handler that logs structured logs at level WARN to a file, etc. I'm pretty sure you can do this now with the code example I have above but it feels kind of hacky overriding the logger property of InstaPy. I think an API for instantiating InstaPy similar to Dave Cheney's Functional options for friendly APIs would be super cool! There's lots of instantiation right now that's hidden from the user but optionally exposing those would be a nice feature. (disclaimer: I haven't put much thought into this, just outlining areas I've had headaches in and some potential solutions to investigate. Hopefully I get some time to come up with some more concrete ideas soon) |
All these sound amazing but currently there is still a huge block issue, which affects the majority of the users... |
Hi everyone, so today I've been digging around in the code and I was looking at the idea of wrapping/refactoring the codebase to closely match the resources (e.g. tags, users, posts, comments). In this way, every resource can have its own distinct class with certain actions (e.g. a post can be liked or commented on) and can be a source to derive other resources from (e.g. post commenters are user objects). The object themselves could have all the attributes needed for filtering, ordering etc. allowing this logic to be handled using regular python operations and easily combined to the high-level functions currently used by most InstaPy users. I think InstaPy refactored/wrapped in this way would be extremely easy to use and be pretty much self-explanatory to use. Below is a quick working example of what I mean for the post resource. Let me know what you guys think.
|
@theveloped this refactor is so clean. I'd be really keen to see how this turns out. If you need help, let me know! |
I've added a very basic version of the proposed wrapper on a fork here. The models (User, Post and Comment) can be found in /instapy/models and some tests in /tests. I'm very curious if people can give some feedback on this approach and if the current approach would fit the InstaPy project as a whole (be suitable for a pull request later on). So let me know what you think. |
Would love to help test and troubleshoot this in lieu of the recent block issues that a lot of users have been experiencing Has anyone been able to figure out what might be triggering the random action blocks for users that were otherwise fine running the same programs before? It seems like web requests sent by the program are identical to normal user interaction and the way elements are clicked doesn't make a difference as far as I can tell. |
Hi All, Also a Python Noob and also seasoned coder in other languages. |
I have been running with the headless browser off and I see that when comments are typed out, they are typed out very quickly. Is it possible to include some kind of delay between typing out each letter so the behavior appears more human? |
I think we need random values in almost every timed functions, so Insta won't find a pattern in bot actions. Another idea is a better analyitics and logging viewer. |
@breuerfelix recently there have been a lot of issues (that I've seen and experienced) running chromedriver on Raspberry Pi - I took a look at the code in browser.py and it's totally geared for Firefox/Gecko so I'm doing a lot of rewriting and refactoring to be able to properly support Chrome. What are your (and anyone else who wants to jump in) thoughts on supporting a single browser? It's easy enough to abstract the construction of the browser object but that has maintenance and support implications. |
are you getting action block in chrome? |
Hello, this is my first contribution/ interaction with this project. |
Ideas / Refactoring
I stumbled across multiple really good ideas for big refactoring.
Before really doing this, we should have a place to discuss the road to 5.0.
You wanna discuss about an idea written here ? Quote the part and answer with your own thoughts ! Quoting is important since this post might change really often, so everybody still knows what the state on your comment was :)
API ideas by @ishandutta2007
I have been meaning to stir this discussion , maybe this is the right thread, we have way too many APIs to do the same or similar things. This kind of design is making it a hell to maintain the code.
How I see is there should be one and only one api which does this three steps:
Choose target user(by tag, or by location, or by hashtag or from Followers/Following of a user, from a specific list).
Choose the desired item of that user(post or profile or comment)
Interact with that item(follow or like or comment).
If we see these three steps separaly we may enhance either of one of these three steps iteratively than trying to create new workflows which are essentially new combination of a usecase of these three steps.
You can expose these three APIs separately or wrap with one. To start we can create a universal wrapper and refactor incrementally later as and when we get opportunity.
HTTP API by @converge
would be awesome if you could wrap up your thoughts here
Extension Management by @breuerfelix
InstaPy package gets an additional folder named
extensions
. Every Extension (like Clarifai in this example) gets its own folder in this directory.Extensions will be programmed only in their folder. This will keep the main codebase clean.
Interaction of Extensions with the core:
We create on Singleton called Event for example. Lets assume Clarifai want to prevent the core loop from liking / commenting some pictures.
There will be a function called
event.before_interaction(image)
. The core function will call this function before liking / commenting a picture and if it returnstrue
it will like it and it will skip it if it returnsfalse
.The clarifai extension can then add its validator function for this event.
event.add_listener('before_interaction', self.validate_picture)
.self.validate_picture
will be a function which checks wether the image is inappropriate or not. (returning true or false).event.before_interaction(image)
is now calling ALL functions added as a listener to its own event and if any of those is returning false, it will return false. Only if all callback functions are returning true, the image will be liked.The users can now just import their clarifai extensions in the main.py
from instapy.extensions import clarifai
and add these to the main instapy objectinstapy.add_extension(clarifai)
.This function will then add all the Listeners to the event object.
That way the core package is able to interact with any amount of extensions without knowing them.
The event singleton may grow in the future and will be the only gate between extensions and the core.
Managing XPaths by @converge and @analyticsdept
Idea: Make a new git repository which contains only the current XPaths. Use jsdelivr to read in the current xpaths from repos master branch on each startup.
this file may be edited by any collaborator ! add your ideas and thoughts.
not a collaborator ? answer to this issue and I will add your ideas into this post !
The text was updated successfully, but these errors were encountered: