Answer the question
In order to leave comments, you need to log in
After compiling the file through pyinstaller, does it say "Fatal error"?
Good afternoon!
Wrote code in python. Pycharm doesn't throw any errors.
When compiling through pyinstaller with the command: "pyinstaller -F -w sample.py" displays an error:
"Failed to execute script sample". Tried through "auto-py-to-exe" the error remained. There was no such error before.
Tell me how to fix it?
Error:
Source code:
from vk_api.longpoll import VkLongPoll
from bs4 import BeautifulSoup
import requests as req
from time import sleep
import random
import vk_api
def write_msg(user_id, message):
vk.method("messages.send", {"peer_id": user_id, "message": message, "random_id": random.randint(100000, 999999)})
resp = req.get("https://gdeposylka.ru/")
mydivs = BeautifulSoup(resp.text, 'lxml').findAll("a", {"rel": "nofollow"})
links = ["https://gdeposylka.ru" + (str(i).split("=")[1].split()[0])[1:-1] + "/" for i in mydivs]
token = "xxx"
vk = vk_api.VkApi(token=token)
longpoll = VkLongPoll(vk)
while True:
trek = "xxx"
l_t = "0"
l_d = "0"
name = "-"
for i in links:
link = i + "tracking/" + trek
resp = req.get(link)
if str(resp) == "<Response [200]>":
soup = BeautifulSoup(resp.text, 'lxml')
mydivs = str(soup.findAll("li", {"style": "display: table; width:100%;table-layout: fixed;"}))
if mydivs != "[]":
time = mydivs.split("\n")[8].split()[0]
date = mydivs.split("\n")[7].split(">")[1].split("<")[0]
event = mydivs.split("\n")[11].lstrip(" ")
place = mydivs.split("\n")[13].lstrip(" ")
if str(time) != str(l_t) or str(date) != str(l_d):
text = "Время: " + str(time) + "\n" + "Дата: " + str(date) + "\n" + "Событие: " + str(event) + "\n" \
+ "Место: " + str(place) + "\n" + "Объект: " + str(name)
write_msg("xxx", text)
l_d = str(date)
l_t = str(time)
break
sleep(300)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question