-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove webscraping for URL #488
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,6 @@ | |
"requests", | ||
"keyring", | ||
"tqdm", | ||
"beautifulsoup4", | ||
"pyyaml", | ||
"xmltodict", | ||
], | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
from open_mastr.xml_download.utils_download_bulk import get_url_from_Mastr_website | ||
import time | ||
from open_mastr.xml_download.utils_download_bulk import gen_url | ||
|
||
def test_gen_url(): | ||
when = time.strptime("2024-01-01", "%Y-%m-%d") | ||
url = gen_url(when) | ||
assert type(url) == str | ||
assert url == "https://download.marktstammdatenregister.de/Gesamtdatenexport_20240101_23.2.zip" | ||
|
||
when = time.strptime("2024-04-01", "%Y-%m-%d") | ||
url = gen_url(when) | ||
assert type(url) == str | ||
assert url == "https://download.marktstammdatenregister.de/Gesamtdatenexport_20240401_23.2.zip" | ||
|
||
when = time.strptime("2024-04-02", "%Y-%m-%d") | ||
url = gen_url(when) | ||
assert type(url) == str | ||
assert url == "https://download.marktstammdatenregister.de/Gesamtdatenexport_20240402_24.1.zip" | ||
|
||
when = time.strptime("2024-10-01", "%Y-%m-%d") | ||
url = gen_url(when) | ||
assert type(url) == str | ||
assert url == "https://download.marktstammdatenregister.de/Gesamtdatenexport_20241001_24.1.zip" | ||
|
||
when = time.strptime("2024-10-02", "%Y-%m-%d") | ||
url = gen_url(when) | ||
assert type(url) == str | ||
assert url == "https://download.marktstammdatenregister.de/Gesamtdatenexport_20241002_24.2.zip" | ||
|
||
def test_get_url_from_Mastr_website(): | ||
url = get_url_from_Mastr_website() | ||
assert len(url) > 10 | ||
when = time.strptime("2024-12-31", "%Y-%m-%d") | ||
url = gen_url(when) | ||
assert type(url) == str | ||
assert "marktstammdaten" in url | ||
assert url == "https://download.marktstammdatenregister.de/Gesamtdatenexport_20241231_24.2.zip" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all thanks for this very useful PR @Johann150
One remark here: I think it would be great to have a fallback url for the case that the current data is not online yet. This could happen, as you described, before 04:00.
Maybe we do the following: When the url is used to download the "Gesamtdatenexport" this is wrapped in a
try
-except
block. If it fails, the url is changed to the url from one day before and the download is started again?What do you think? And do you have time to make this change? Otherwise I can also do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the change. It was previously not checked at all what the download request status code was, so instead of writing a giant
try
block I thought it would be a better idea to "just" check the status code instead.There is one potential situation that I'm not quite sure about, when thinking about this a bit more. Since the download can take a few minutes, if by coincidence you were to start the download right before the new file is published, I don't know if the rest of the old file will be correctly downloaded. But maybe that is a very hypothetical and contrived situation that does not really need to be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that won't happen too often and people can than rerun the download.