Я написал программу на Python, которая загружает истории моих подписчиков в instgram, но когда я помещаю этот проект на хост, он просто открывает Интернет, и когда я ввожу имя пользователя и пароль, он не загружает истории и не говорит эту ошибку: EOFError : EOF при чтении строки '' в cpanel
there mu python code:
from flask import Flask, render_template, request, send_file
from instagrapi import Client
import os
import shutil
import zipfile
app = Flask(__name__)
# Ensure the download directory exists
DOWNLOAD_DIR = "downloads"
if not os.path.exists(DOWNLOAD_DIR):
os.makedirs(DOWNLOAD_DIR)
@app.route('/', methods=['GET'])
def home():
return render_template('index.html')
@app.route('/download', methods=['POST'])
def download_stories():
username = request.form['username']
password = request.form['password']
cl = Client()
cl.login(username, password)
following_users = cl.user_following(cl.user_id)
# Create a directory for the user stories
user_stories_dir = os.path.join(DOWNLOAD_DIR, username)
if not os.path.exists(user_stories_dir):
os.makedirs(user_stories_dir)
# Loop through each user the logged-in user is following
for user in following_users:
user_id = user
user_info = cl.user_info(user_id)
followed_username = user_info.username
# Download stories for the current user
stories = cl.user_stories(user_id)
for story in stories:
story_url = story.video_url or story.thumbnail_url
file_extension = ".jpg" if story.thumbnail_url else ".mp4"
filename = os.path.join(user_stories_dir, f"{followed_username}_{story.pk}{file_extension}")
story_content = cl.story_download(story.pk)
if isinstance(story_content, str) or isinstance(story_content, bytes):
with open(filename, "wb") as f:
f.write(story_content)
elif hasattr(story_content, 'name'):
shutil.move(story_content, filename)
# Create a zip file of the downloaded stories
zip_filename = os.path.join(DOWNLOAD_DIR, f"{username}_stories.zip")
with zipfile.ZipFile(zip_filename, 'w') as zipf:
for root, _, files in os.walk(user_stories_dir):
for file in files:
zipf.write(os.path.join(root, file), file)
return send_file(zip_filename, as_attachment=True)
@app.route('/downloads/', methods=['GET'])
def download_file(filename):
return send_file(os.path.join(DOWNLOAD_DIR, filename), as_attachment=True)
if __name__ == '__main__':
app.run(debug=True)
Подробнее здесь: https://stackoverflow.com/questions/790 ... -in-cpanel
EOFError: EOF при чтении строки в cpanel ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Traceback (последний вызов последний): EOFError: EOF при чтении строки [закрыто]
Anonymous » » в форуме Python - 0 Ответы
- 25 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Traceback (последний вызов последний): EOFError: EOF при чтении строки [закрыто]
Anonymous » » в форуме Python - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Есть ли решение запустить команду задания cron в cpanel только с моего хоста cPanel?
Anonymous » » в форуме Php - 0 Ответы
- 72 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Сообщения об ошибках OpenSSL: ошибка: 0A000126: процедуры SSL:: неожиданный eof при чтении
Anonymous » » в форуме Php - 0 Ответы
- 30 Просмотры
-
Последнее сообщение Anonymous
-