-
-
Save Suleman-Elahi/3b6c1e02ead4c849ceb7e70955b55180 to your computer and use it in GitHub Desktop.
from instagram_private_api import Client, ClientCompatPatch | |
from instagram_private_api_extensions import pagination | |
import json, time | |
user_name = 'UserName' | |
password = 'PassWord' | |
api = Client(user_name, password) | |
items=[] | |
for results in pagination.page(api.saved_feed, args={}): | |
if results.get('items'): | |
items.extend(results['items']) | |
print("Starting unsaving posts.....") | |
for i,x in enumerate(items): | |
z = items[i]['media']['pk'] | |
api.unsave_photo(media_id=z) | |
time.sleep(3) | |
print("Unsaved: ", z) |
@Suleman-Elahi
Hi !
Thanks for reply!
I guess I did not express my thoughts correctly. The script currently does not unsave videos and posts with multiple pictures.
@Suleman-Elahi Could you please tell how to delete stories archive in one click?
Traceback (most recent call last):
File "C:\Users\ranai\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\instagram_private_api\client.py", line 523, in _call_api
response = self.opener.open(req, timeout=self.timeout)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ranai\Documents\unsaver.py", line 8, in
api = Client(user_name, password)
File "C:\Users\ranai\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\instagram_private_api\client.py", line 208, in init
self.login()
File "C:\Users\ranai\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\instagram_private_api\endpoints\accounts.py", line 49, in login
login_response = self._call_api(
File "C:\Users\ranai\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\instagram_private_api\client.py", line 527, in _call_api
ErrorHandler.process(e, error_response)
File "C:\Users\ranai\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\instagram_private_api\errors.py", line 123, in process
raise error_info['error'](
instagram_private_api.errors.ClientCheckpointRequiredError: checkpoint_challenge_required
PS C:\Users\ranai\Documents>
@FetraRanaivoson you have either triggered the anti abuse detection system of Instagram or you have 2FA enabled.
@Suleman-Elahi Ok, I have already disabled 2FA yesterday. So how could I solve this? IG keeps notify me to change my password each time ...
@Suleman-Elahi Ok, I have already disabled 2FA yesterday. So how could I solve this? IG keeps notify me to change my password each time ...
You will have to wait for a few days...or you can use VPN with server in the same country as you. Or, if you can get your ISP to give you a new IP address then perhaps it can be solved.
@GetIt7788 open terminal in the folder where the unsaver.py file. And then run it like this python unsaver.py
if it errors then tell me. It should work though.
403 forbidden likely cased for abusing the API. Try after using a VPN and make sure that account doesn't have 2FA enabled.
@N1kRolexx Deletion would be another thing. This script is just for unsaving posts. For post deletion, there will be a different function in the API.