fix book form cover url error
This commit is contained in:
parent
5e2720ebe3
commit
964ddf697f
2 changed files with 7 additions and 6 deletions
|
@ -2,6 +2,7 @@ from django import forms
|
|||
from django.contrib.postgres.forms import JSONField
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from boofilsic.settings import MEDIA_URL
|
||||
import json
|
||||
|
||||
|
||||
|
@ -66,7 +67,7 @@ class ImageInput(forms.FileInput):
|
|||
Return the file object if it has a defined url attribute.
|
||||
"""
|
||||
if self.is_initial(value):
|
||||
return value
|
||||
return MEDIA_URL + value
|
||||
|
||||
def is_initial(self, value):
|
||||
"""
|
||||
|
|
|
@ -24,8 +24,8 @@ DEFAULT_REQUEST_HEADERS = {
|
|||
TIMEOUT = 10
|
||||
|
||||
# luminati account credentials
|
||||
USERNAME = '***REMOVED***'
|
||||
PASSWORD = '***REMOVED***'
|
||||
USERNAME = 'lum-customer-hl_124-zone-static'
|
||||
PASSWORD = 'tvt'
|
||||
PORT = 22225
|
||||
|
||||
|
||||
|
@ -37,8 +37,8 @@ def scrape_douban_book(url):
|
|||
'http': proxy_url,
|
||||
'https': proxy_url,
|
||||
}
|
||||
# r = requests.get(url, proxies=proxies, headers=DEFAULT_REQUEST_HEADERS, timeout=TIMEOUT)
|
||||
r = requests.get(url, headers=DEFAULT_REQUEST_HEADERS, timeout=TIMEOUT)
|
||||
r = requests.get(url, proxies=proxies, headers=DEFAULT_REQUEST_HEADERS, timeout=TIMEOUT)
|
||||
# r = requests.get(url, headers=DEFAULT_REQUEST_HEADERS, timeout=TIMEOUT)
|
||||
|
||||
content = html.fromstring(r.content.decode('utf-8'))
|
||||
|
||||
|
@ -103,7 +103,7 @@ def scrape_douban_book(url):
|
|||
'cache-control': 'no-cache',
|
||||
'dnt': '1' ,
|
||||
},
|
||||
# proxies=proxies,
|
||||
proxies=proxies,
|
||||
timeout=TIMEOUT,
|
||||
)
|
||||
if img_response.status_code == 200:
|
||||
|
|
Loading…
Add table
Reference in a new issue