Malka yehudit - #2
Open
MalkaYehudit wants to merge 4 commits into
Open
Conversation
ShaniShurkin
approved these changes
Jul 1, 2025
| from selenium.webdriver.chrome.service import Service | ||
|
|
||
| ZAP_MARKET_URL = "https://www.zapmarket.co.il/" | ||
| CHROMEDRIVER_PATH = 'C:\Program Files\chromedriver-win64/chromedriver.exe' |
Collaborator
There was a problem hiding this comment.
ניתוב כזה עובד רק על המחשב שלך, ולא יעבוד למישהו אחר שינסה להריץ.
יש כמה אופציות לפתרון, הדרך המומלצת ביותר היא שימוש ב-webdriver_manager
הספריה webdriver_manager מנהלת הורדה והתקנה של ה-WebDriver המתאים באופן אוטומטי. זה אומר שכל משתמש שמריץ את הקוד לא צריך לדאוג להורדת ChromeDriver ידנית.
הצעדים כדי לעשות את זה:
התקן את הספרייה: pip install webdriver-manager
שנה את הקוד שלך:
במקום לציין נתיב קשיח, השתמש ב-ChromeDriverManager:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
השתמש ב-ChromeDriverManager כדי להוריד ולהגדיר את ה-ChromeDriver
service = ChromeService(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
|
|
||
| def scroll_to_bottom(self): | ||
| self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") | ||
| time.sleep(2) |
Collaborator
There was a problem hiding this comment.
עדיף להימנע כמה שיותר מtime.sleep()ץ רק במקרים של חוסר ברירה
עדיף שתגדילי את WebDriverWait(self.driver, timeout).until ותוסיפי תנאים
| self.close_promo_if_exists() | ||
| self.driver.execute_script("arguments[0].scrollIntoView();", update_button) | ||
| self.driver.execute_script("arguments[0].click();", update_button) | ||
| time.sleep(1) |
| simplified_name = product_name.split()[0] | ||
| best_match, best_ratio = find_best_match(simplified_name) | ||
|
|
||
| if not best_match or best_ratio < 0.3: |
Collaborator
There was a problem hiding this comment.
יכול להיות ש0.3 מדי נמוך, ניסית להגדיל אותו?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
selenium zap market