Skip to content

Commit f0321b6

Browse files
committed
fix(scraper/web): clear previous marks when init data
1 parent 6c74226 commit f0321b6

File tree

1 file changed

+13
-0
lines changed
  • npiai/tools/scrapers/web

1 file changed

+13
-0
lines changed

npiai/tools/scrapers/web/app.py

+13
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ async def init_data(self, ctx: Context):
8787
wait_for_selector=self.items_selector,
8888
force_capcha_detection=True,
8989
)
90+
else:
91+
# clear visited marks and scroll to the top
92+
await self.playwright.page.evaluate(
93+
"""
94+
() => {
95+
window.scrollTo(0, 0);
96+
97+
[...document.querySelectorAll('[data-npi-visited]')].forEach(e => {
98+
e.removeAttribute('data-npi-visited');
99+
});
100+
}
101+
"""
102+
)
90103

91104
async def next_items(
92105
self,

0 commit comments

Comments
 (0)