Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 3afa60f

Browse files
Update economictimes_scraper.py
1 parent c43a74c commit 3afa60f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

‎Scripts/Web_Scrappers/Economictimes_Scraper/economictimes_scraper.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import datetime
66
import sys
77

8-
## Util
8+
# Util
99
def datestr_to_date(datestr):
1010
[year, month, day] = datestr.split('-')
1111
return datetime.date(
@@ -14,8 +14,8 @@ def datestr_to_date(datestr):
1414
day=int(day)
1515
)
1616

17-
## Reference dates
18-
reference_date = datetime.date(2001, 1, 1) ## 2001 Jan 1
17+
# Reference dates
18+
reference_date = datetime.date(2001, 1, 1) # 2001 Jan 1
1919
reference_date_id = 36892
2020

2121
if len(sys.argv) < 3:
@@ -35,7 +35,7 @@ def datestr_to_date(datestr):
3535
sys.exit(1)
3636

3737

38-
## Gets News article metadata from article url
38+
# Gets News article metadata from article url
3939
def fetchNewsArticle(url):
4040
html = requests.get(url).content
4141
root = defusedxml.HTML(html)
@@ -66,6 +66,5 @@ def fetchNewsArticle(url):
6666
})
6767

6868
out_filename = 'ET_NewsData_{}_{}.json'.format(start_date, end_date)
69-
output_file = open(out_filename, 'w+')
70-
output_file.write(json.dumps(fetched_data, indent=2))
71-
output_file.close()
69+
with open(out_filename, 'w+') as output_file:
70+
output_file.write(json.dumps(fetched_data, indent=2))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /