Skip to content

Commit

Permalink
Fix Offer Detection in buyResources.py (#299)
Browse files Browse the repository at this point in the history
* Update buyResources.py

Offers are now detected and sorted properly.

* Update buyResources.py
  • Loading branch information
Hayato500 authored Jan 24, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 48ff024 commit fd30cec
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ikabot/function/buyResources.py
Original file line number Diff line number Diff line change
@@ -70,9 +70,18 @@ def getOffers(session, city):
"""
html = getMarketHtml(session, city)
hits = re.findall(
r'short_text80">(.*?) *<br/>\((.*?)\)\s *</td>\s *<td>(\d+)</td>\s *<td>(.*?)/td>\s *<td><img src="(.*?)\.png[\s\S]*?white-space:nowrap;">(\d+)\s[\s\S]*?href="\?view=takeOffer&destinationCityId=(\d+)&oldView=branchOffice&activeTab=bargain&cityId=(\d+)&position=(\d+)&type=(\d+)&resource=(\w+)"',
r'short_text80">(.*?) <br/>\((.*?)\)\s*</td>\s*<td>(\d+)</td>\s*<td>([\d,\s]+)(?:<div class="tooltip">.*?)?</td>\s*<td><img src="([^"]+\.png)"[\s\S]*?white-space:nowrap;">(\d+)\s*[\s\S]*?href="\?view=takeOffer&destinationCityId=(\d+)&oldView=branchOffice&activeTab=bargain&cityId=(\d+)&position=(\d+)&type=(\d+)&resource=(\w+)"',
html,
re.DOTALL
)

# Clean up the hits by stripping whitespace from each captured string
cleaned_hits = []
for hit in hits:
cleaned_hit = tuple(item.strip() for item in hit) # Strip whitespace from each item
cleaned_hits.append(cleaned_hit)
hits = cleaned_hits

offers = []
for hit in hits:
offer = {

0 comments on commit fd30cec

Please sign in to comment.