Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
erlichsefi committed Oct 11, 2024
1 parent 4fd4d5f commit 9aed2c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
3 changes: 1 addition & 2 deletions il_supermarket_scarper/engines/apsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def get_request_url(self, files_types=None, store_id=None, when_date=None):
@abstractmethod
def get_href_from_entry(self, entry):
"""get download link for entry (tr)"""

@abstractmethod
def get_file_name_no_ext_from_entry(self, entry):
"""get the file name without extensions from entey (tr)"""

6 changes: 2 additions & 4 deletions il_supermarket_scarper/engines/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _get_all_possible_query_string_params(
# )
# post_body.append(
# {

# "ctl00$TextArea": "",
# "ctl00$MainContent$chain": chain_id,
# "ctl00$MainContent$subChain": "-1",
Expand Down Expand Up @@ -134,7 +134,5 @@ def get_data_from_page(self, req_res):
all_trs = list(
filter(lambda x: x and self.chain_hebrew_name in str(x), all_trs)
)
Logger.info(
f"Found {len(all_trs)} entries"
)
Logger.info(f"Found {len(all_trs)} entries")
return all_trs
4 changes: 2 additions & 2 deletions il_supermarket_scarper/engines/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def collect_files_details_from_site(
files_names_to_scrape=None,
):
"""collect all enteris to download from site"""
#self.session_with_cookies_by_chain(self.url, method="GET")

urls_to_collect_link_from = self.get_request_url(
files_types=files_types, store_id=store_id, when_date=when_date
)
all_trs = []
for url in urls_to_collect_link_from:
req_res = self.session_with_cookies_by_chain(**url)
req_res = session_and_check_status(**url)
trs = self.get_data_from_page(req_res)
all_trs.extend(trs)

Expand Down
7 changes: 3 additions & 4 deletions il_supermarket_scarper/utils/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import subprocess

from http.client import RemoteDisconnected
from http.cookiejar import MozillaCookieJar
from http.cookiejar import LoadError
from urllib.error import URLError
from urllib3.exceptions import MaxRetryError, ReadTimeoutError
Expand Down Expand Up @@ -195,9 +194,9 @@ def session_with_cookies(
session = requests.Session()
filename = f"{chain_cookie_name}_cookies.txt"
if chain_cookie_name:

try:
with open(filename, 'rb') as f:
with open(filename, "rb") as f:
session.cookies.update(pickle.load(f))
# session.cookies.load()
except FileNotFoundError:
Expand Down Expand Up @@ -225,7 +224,7 @@ def session_with_cookies(
)

if chain_cookie_name and not os.path.exists(filename):
with open(filename, 'wb') as f:
with open(filename, "wb") as f:
pickle.dump(session.cookies.get_dict(), f)

return response_content
Expand Down

0 comments on commit 9aed2c2

Please sign in to comment.