Posted 1 year ago
·
Author
Hello guys. As described in the title, i needed to save my wishlist on imvu, but I couldn't find anything that could help me. So I ended up making this "tool", or rather... This program that you can run it, log into the fake account and save all the items that are on your list, I hope this helps in some way...
I have no intention of continuing this little project, because the way it is now, serves me very well...
But I'll leave the source code so you can do something if you want. Feel free to do whatever you want.
ps: I don't know much about python, so I had a lot of help from gpt-3
source-code (python):
Below is the program compiled with pyinstaller, just run it and put the necessary information. Remembering that there is no error handling when placing the information, so... if you make a mistake, the code will return errors.
I have no intention of continuing this little project, because the way it is now, serves me very well...
But I'll leave the source code so you can do something if you want. Feel free to do whatever you want.
ps: I don't know much about python, so I had a lot of help from gpt-3
source-code (python):
# Import necessary modules
import builtins
import easygui
import json
import re
import time
from typing import List
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
# Define custom input function to use easygui
def input(prompt=''):
return easygui.enterbox(prompt)
# Replace built-in input function with custom input function
builtins.input = input
# Define function to get login information from user
def get_login_info() -> tuple:
username = input("Digite seu nome de usuário: ")
password = input("Digite sua senha: ")
cid = input("Digite o CID: ")
return username, password, cid
# Define function to log-in
def login(driver: webdriver.Chrome, login_url: str, username: str, password: str) -> None:
# Load the login page URL
driver.get(login_url)
# Wait until the sign-in button is present on the page
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "sign-in")))
# Find the sign-in button element and click it
login_button = driver.find_element(By.CLASS_NAME, "sign-in")
login_button.click()
# Wait for 3 seconds for the page to load
time.sleep(3)
# Find the username input element and enter the username
username_input = driver.find_element(By.NAME, "avatarname")
username_input.send_keys(username)
# Find the password input element and enter the password
password_input = driver.find_element(By.NAME, "password")
password_input.send_keys(password)
# Submit the login form by pressing the Enter key on the keyboard
password_input.send_keys(Keys.ENTER)
# Wait for 5 seconds for the login process to complete
time.sleep(5)
def extract_wishlist_ids(driver: webdriver.Chrome, cid: str) -> List[str]:
# Access the wishlist API endpoint for the user with the given cid
driver.get(f"https://api.imvu.com/user/user-{cid}/wishlist?start_index=1&limit=900")
# Wait for the page to load before accessing the response
time.sleep(5)
# Find the response element on the page and extract its text
response = driver.find_element(By.TAG_NAME, "pre")
response_json = json.loads(response.text)
# Wait for the page to finish processing before continuing
time.sleep(5)
# Extract the wishlist ids from the response JSON
wishlist_ids = set()
for resp in response_json["denormalized"]:
match = re.search(r"product-(\d+)", resp)
if match:
wishlist_ids.add(match.group(1))
# Return the set of wishlist ids
return wishlist_ids
def add_to_wishlist(driver: webdriver.Chrome, product_id: str) -> None:
# go to the product page
driver.get(f"https://pt.imvu.com/shop/product.php?products_id={product_id}")
time.sleep(1)
try:
# get the product name
product_name = driver.find_element(By.CSS_SELECTOR,"h1.notranslate").text
# find the 'Add to Wishlist' button
add_to_wishlist_button = driver.find_element(By.CSS_SELECTOR,"a#add-to-wishlist")
# ask user if they want to add the item to wishlist
choice = easygui.buttonbox(f"Do you want to save {product_name} to your wishlist?", choices=["Yes", "No"])
if choice == "Yes":
# click the 'Add to Wishlist' button
add_to_wishlist_button.click()
print(f"Item {product_name} added to wishlist")
return True
else:
print(f"Item {product_name} not added to wishlist")
return False
except NoSuchElementException:
# if the product is not found
print(f"Item {product_id} not found. Moving on to the next item.")
return False
def add_to_wishlist_no_button_box(driver: webdriver.Chrome, product_id: str) -> None:
# Navigate to the product page
driver.get(f"https://pt.imvu.com/shop/product.php?products_id={product_id}")
time.sleep(1)
try:
# Get the name of the product
product_name = driver.find_element(By.CSS_SELECTOR, "h1.notranslate").text
# Click the "Add to Wishlist" button
add_to_wishlist_button = driver.find_element(By.CSS_SELECTOR, "a#add-to-wishlist")
add_to_wishlist_button.click()
# Print a success message
print(f"Item {product_name} added to wishlist")
return True
except NoSuchElementException:
# Print an error message if the product is not found
print(f"Item {product_id} not found. Moving on to the next item.")
return False
def main():
# Login page URL
login_url = "https://secure.imvu.com/welcome/login/"
# Get login information
username, password, cid = get_login_info()
# Configure Google Chrome webdriver settings
options = Options()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
options.add_argument("--start-maximized")
driver = webdriver.Chrome(options=options)
# Log in
login(driver, login_url, username, password)
# Extract wishlist IDs
wishlist_ids = extract_wishlist_ids(driver, cid)
# Ask user if they want to save all items without showing a confirmation box
save_all = easygui.ynbox("Do you want to save all items without showing a confirmation box?", "Save all items")
# Loop through each item in the wishlist and add it to the user's wishlist
founded = 0 # Number of items successfully added to wishlist
not_founded = 0 # Number of items that could not be added to wishlist
for product_id in wishlist_ids:
if not save_all:
# Ask the user if they want to add the current item to their wishlist
if add_to_wishlist(driver, product_id):
founded += 1
else:
not_founded += 1
else:
# Add the current item to the wishlist without asking for confirmation
if add_to_wishlist_no_button_box(driver, product_id):
founded += 1
else:
not_founded += 1
# Wait for 1 second before processing the next item in the wishlist
time.sleep(1)
# Print the number of items that were successfully added and those that could not be added
print(f"{founded} items were added to the wishlist, and {not_founded} items could not be added.")
# Wait 20 seconds after all
time.sleep(20)
# say goodbye baby
driver.quit()
if __name__ == "__main__":
main()
Below is the program compiled with pyinstaller, just run it and put the necessary information. Remembering that there is no error handling when placing the information, so... if you make a mistake, the code will return errors.
saveWishlistRar.rar