Created
December 13, 2020 08:59
-
-
Save audhiaprilliant/812292aed53ad5883dd08f58bf832a0b to your computer and use it in GitHub Desktop.
Apache Airflow as Job Orchestration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create dictionary for date manipulation | |
| dict_month = {'Januari':'01','Februari':'02','Maret':'03','April':'04','Mei':'05','Juni':'06','Juli':'07','Agustus':'08','September':'09','Oktober':'10','November':'11','Desember':'12'} | |
| # Function to get the current date | |
| def get_current_date(**kwargs): | |
| date_scrape = soup.find('span',class_='covid__date').text | |
| date_scrape = re.findall(r'Update terakhir: (\S+.+WIB)',date_scrape)[0].replace(', ',',') | |
| date = date_scrape.split(',')[0] | |
| time = date_scrape.split(',')[1] | |
| # Date manipulation | |
| date_format = re.findall(r'\w+',date)[0] | |
| month_format = re.findall(r'\w+',date)[1] | |
| year_format = re.findall(r'\w+',date)[2] | |
| # If condition | |
| if len(date_format) == 1: | |
| date_format = '0' + date_format | |
| else: | |
| date_format = date_format | |
| # New date format | |
| date = year_format+'/'+dict_month.get(month_format)+'/'+date_format | |
| return(date,time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment