retry
Browse filesSigned-off-by: Balazs Horvath <acsipont@gmail.com>
- crawl/crawl +15 -4
crawl/crawl
CHANGED
@@ -175,14 +175,25 @@ if __name__ == "__main__":
|
|
175 |
nargs="+",
|
176 |
help="List of URLs to crawl"
|
177 |
)
|
|
|
|
|
|
|
|
|
|
|
178 |
args = parser.parse_args()
|
179 |
|
180 |
for url in args.urls:
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
try:
|
183 |
save_result(url)
|
184 |
-
break
|
185 |
except (AttributeError, ValueError) as e:
|
186 |
print(f"[ERROR] 🚫 Failed to crawl {url}, error: {str(e)}")
|
187 |
-
print("Retrying in 3 seconds...")
|
188 |
-
time.sleep(3)
|
|
|
175 |
nargs="+",
|
176 |
help="List of URLs to crawl"
|
177 |
)
|
178 |
+
parser.add_argument(
|
179 |
+
"--retry",
|
180 |
+
action="store_true",
|
181 |
+
help="Retry crawling indefinitely every 3 seconds until successful"
|
182 |
+
)
|
183 |
args = parser.parse_args()
|
184 |
|
185 |
for url in args.urls:
|
186 |
+
if args.retry:
|
187 |
+
while True:
|
188 |
+
try:
|
189 |
+
save_result(url)
|
190 |
+
break
|
191 |
+
except (AttributeError, ValueError) as e:
|
192 |
+
print(f"[ERROR] 🚫 Failed to crawl {url}, error: {str(e)}")
|
193 |
+
print("Retrying in 3 seconds...")
|
194 |
+
time.sleep(3)
|
195 |
+
else:
|
196 |
try:
|
197 |
save_result(url)
|
|
|
198 |
except (AttributeError, ValueError) as e:
|
199 |
print(f"[ERROR] 🚫 Failed to crawl {url}, error: {str(e)}")
|
|
|
|