| 1 |
import requests |
| 2 |
|
| 3 |
from celery import shared_task |
| 4 |
|
| 5 |
|
| 6 |
@shared_task() |
| 7 |
def urlopen(url): |
| 8 |
print(f'-open: {url}') |
| 9 |
try: |
| 10 |
response = requests.get(url) |
| 11 |
except requests.exceptions.RequestException as exc: |
| 12 |
print(f'-url {url} gave error: {exc!r}') |
| 13 |
return |
| 14 |
return len(response.text) |