You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
617 B
Python

5 years ago
from contextlib import contextmanager
import functools
import logging
import os
import tempfile
from bs4 import BeautifulSoup as bs
import requests
logger = get_logger()
@contextmanager
def working_dir(directory):
original_working_dir = os.getcwd()
try:
os.chdir(directory)
yield directory
finally:
os.chdir(original_working_dir)
def download(url, filepath):
response = request_get(url)
data = response.content
with open(filepath, "wb") as f:
f.write(data)
def make_tempdir(identifier):
return tempfile.mkdtemp(prefix="{}_".format(identifier))