-
-
Notifications
You must be signed in to change notification settings - Fork 141
feat(ariz, arizctapp_div_1): rewrite scrapers to use new JSON API #1740
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
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
flooie
left a comment
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.
Nice fix, but lets make it a little less brittle
…ing' into 1707-arizctapp_div_1-is-not-working
for more information, see https://pre-commit.ci
flooie
left a comment
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 think we have a little bit of work to do here, but overall its good to get it working
|
In _set_auth_headers (lines 91, 94), I still use minimal regex to extract values after XPath locates the elements:
html.xpath(self.tab_xp)[0].split("`")[-2] raise "index error" |
| days_interval = 30 | ||
|
|
||
| # XPaths for extracting authentication values | ||
| module_xp = "//div[contains(@id, 'app-container-')]/@id" |
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 prefer this
module_xp = "//div[@id='dnn_ContentPane']/div/a/@name"
and your method can be
def _set_auth_headers(self) -> None:
"""Extract and set authentication headers from HTML page.
:param html: Parsed HTML page (lxml element)
:return: None
"""
tab_script = self.html.xpath(self.tab_xp)[0]
tab_id = re.search(r'"tabId":(\d+)', tab_script).group(1)
self.request["headers"].update(
{
"ModuleId": self.html.xpath(self.module_xp)[0],
"TabId": tab_id,
"RequestVerificationToken": self.html.xpath(self.token_xp)[0],
}
)
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 would just do this as well in download
self.html = super()._download()
self._set_auth_headers()
for more information, see https://pre-commit.ci
…ing' into 1707-arizctapp_div_1-is-not-working
fixes #1707