mirror of
https://github.com/guezoloic/millesima_projetS6.git
synced 2026-03-28 19:13:42 +00:00
Compare commits
3 Commits
e6c649b433
...
0d96ff7714
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d96ff7714 | |||
| ebd9d15f77 | |||
| 8a888f583c |
@@ -434,6 +434,7 @@ class Scraper:
|
|||||||
# processus en entier.
|
# processus en entier.
|
||||||
serializable: tuple[int, set[str]] | None = loadstate()
|
serializable: tuple[int, set[str]] | None = loadstate()
|
||||||
if isinstance(serializable, tuple):
|
if isinstance(serializable, tuple):
|
||||||
|
# override la page et le cache
|
||||||
page, cache = serializable
|
page, cache = serializable
|
||||||
try:
|
try:
|
||||||
with open(filename, mode) as f:
|
with open(filename, mode) as f:
|
||||||
@@ -465,7 +466,7 @@ class Scraper:
|
|||||||
)
|
)
|
||||||
self._writevins(cache, product, f)
|
self._writevins(cache, product, f)
|
||||||
page += 1
|
page += 1
|
||||||
except Exception:
|
except (Exception, HTTPError, KeyboardInterrupt, JSONDecodeError):
|
||||||
if not reset:
|
if not reset:
|
||||||
savestate((page, cache))
|
savestate((page, cache))
|
||||||
|
|
||||||
@@ -473,8 +474,11 @@ class Scraper:
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
if len(argv) != 3:
|
if len(argv) != 3:
|
||||||
raise ValueError(f"{argv[0]} <filename> <sous-url>")
|
raise ValueError(f"{argv[0]} <filename> <sous-url>")
|
||||||
|
filename = argv[1]
|
||||||
|
suburl = argv[2]
|
||||||
|
|
||||||
scraper: Scraper = Scraper()
|
scraper: Scraper = Scraper()
|
||||||
scraper.getvins(argv[2], argv[1])
|
scraper.getvins(suburl, filename)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user