Skip to content

Commit

Permalink
Code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Jan 31, 2025
1 parent a2abaca commit 59ac4f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ai_marketplace_monitor/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def search(
if not self.filter_item(item, item_config):
continue
try:
details = self.get_item_details(item.post_url)
details = self.get_item_details(f"https://www.facebook.com{item.post_url}")
time.sleep(5)
except Exception as e:
self.logger.error(f"Error getting item details: {e}")
Expand All @@ -305,7 +305,7 @@ def get_item_details(self: "FacebookMarketplace", post_url: str) -> SearchedItem
self.login()

assert self.page is not None
self.goto_url(f"https://www.facebook.com{post_url}")
self.goto_url(post_url)
details = FacebookItemPage(self.page.content(), self.logger).parse(post_url)
cache.set((CacheType.ITEM_DETAILS.value, post_url), details, tag="item_details")
return details
Expand Down
6 changes: 3 additions & 3 deletions src/ai_marketplace_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ def check_items(
for post_url in post_urls or []:
if "?" in post_url:
post_url = post_url.split("?")[0]
if post_url.startswith("https://www.facebook.com"):
post_url = post_url[len("https://www.facebook.com") :]
if post_url.isnumeric():
post_url = f"/marketplace/item/{post_url}/"
post_url = f"https://www.facebook.com/marketplace/item/{post_url}/"

if not post_url.startswith("https://www.facebook.com/marketplace/item"):
raise ValueError(f"URL {post_url} is not a valid Facebook Marketplace URL.")
# check if item in config
assert self.config is not None

Expand Down

0 comments on commit 59ac4f4

Please sign in to comment.