-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathget_page_content.py
More file actions
33 lines (26 loc) · 949 Bytes
/
Copy pathget_page_content.py
File metadata and controls
33 lines (26 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
This example shows how to get the main slot or html content of a OSW page
prerequisite: valid bot password in the used OSW instance (Log in, then
go to special pages -> Bot passwords ; follow the instructions)
"""
import dotenv
from osw.express import OswExpress
from osw.params import GetPageParam
dotenv.load_dotenv()
osw = OswExpress(domain="demo.open-semantic-lab.org")
# the page title of the page to downlaod
# Demo Article
fullpagetitle_to_download = "Item:OSWac34aa10f897463f966724d86eece3da"
# getting the page content from the main slot (without info box...)
page_content = (
osw.site
.get_page(GetPageParam(titles=[fullpagetitle_to_download]))
.pages[0]
.get_slot_content("main")
)
print(page_content)
# getting the html of the actually visible page including info-box and further elements
page_html = osw.site._site.raw_api(
action="parse", page=fullpagetitle_to_download, format="json"
)
print(page_html)