commit
e618e5da8d
|
@ -66,7 +66,11 @@ def test_pdf(pdf_file):
|
||||||
def staple_pdf(urllist, user_agent=settings.USER_AGENT):
|
def staple_pdf(urllist, user_agent=settings.USER_AGENT):
|
||||||
merger = PdfFileMerger(strict=False)
|
merger = PdfFileMerger(strict=False)
|
||||||
for url in urllist:
|
for url in urllist:
|
||||||
|
try:
|
||||||
response = requests.get(url, headers={"User-Agent": user_agent})
|
response = requests.get(url, headers={"User-Agent": user_agent})
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
logger.error("Error getting url: %s", url)
|
||||||
|
return None
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
try:
|
try:
|
||||||
merger.append(BytesIO(response.content))
|
merger.append(BytesIO(response.content))
|
||||||
|
|
Loading…
Reference in New Issue