Last active
January 3, 2026 12:45
-
-
Save Romern/d1ca7497988b6ce456a1cd9f4a0f9500 to your computer and use it in GitHub Desktop.
Studocu Druckansicht
This file contains hidden or 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
| import requests | |
| from pathlib import Path | |
| import uuid | |
| headers = { | |
| 'X-Session-Id': str(uuid.uuid4()), | |
| 'X-Request-Id': str(uuid.uuid4()) | |
| } | |
| base_html = Path('./base.html').read_text() | |
| document_id = '4115150' | |
| file_access = requests.get(f'https://api.studocu.com/rest-api/v1/documents/{document_id}/file/access', headers=headers) | |
| if file_access.status_code != 200: | |
| print(f'Blocked by cloudflare or document invalid (Code {file_access.status_code}):') | |
| print(file_access.text) | |
| exit() | |
| file_access_json = file_access.json() | |
| meta_data = requests.get(f'https://api.studocu.com/rest-api/v1/documents/{document_id}', headers=headers) | |
| if meta_data.status_code != 200: | |
| print(f'Blocked by cloudflare or document invalid (Code {meta_data.status_code}):') | |
| print(meta_data.text) | |
| exit() | |
| meta_data_json = meta_data.json() | |
| num_pages = meta_data_json['data']['numberOfPages'] | |
| structure_template = ''' '<div id="pfPAGENO" class="pf w0 h0" data-page-no="PAGENO"></div>',''' | |
| structure = "".join([structure_template.replace('PAGENO', str(i)) for i in range(1,num_pages+1)]) | |
| Path('out.html').write_text(base_html.replace('ASSETIDREPLACEPOSITION', | |
| file_access_json['data']['objectKey']) | |
| .replace('SIGNEDQUERYPARAMS', | |
| file_access_json['data']['signedQueryParams']['global']) | |
| .replace("PAGECOUNT",str(num_pages)) | |
| .replace("STRUCTUREPLACEHOLDER",structure)) |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | |
| <head prefix="og:https://ogp.me/ns#"> | |
| <meta charSet="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
| <title>Studocu - Free summaries, lecture notes & exam prep</title> | |
| <link rel="preconnect" href="https://website-assets.studocu.com" /> | |
| <link rel="preconnect" href="https://cdn.segment.com" /> | |
| <link rel="preconnect" href="https://cdn.mxpnl.com" /> | |
| <link rel="icon" href="https://website-assets.studocu.com/img/favicon.svg" type="image/svg+xml" sizes="any" /> | |
| <link rel="alternate icon" href="https://website-assets.studocu.com/img/favicon.ico" type="image/x-icon" | |
| sizes="any" /> | |
| <link rel="mask-icon" href="https://website-assets.studocu.com/img/apple/mask-icon.svg" color="black" /> | |
| <link rel="apple-touch-icon" href="https://website-assets.studocu.com/img/apple/apple-touch-icon.png" /> | |
| <link rel="apple-touch-icon" sizes="76x76" | |
| href="https://website-assets.studocu.com/img/apple/apple-touch-icon-76x76.png" /> | |
| <link rel="apple-touch-icon" sizes="120x120" | |
| href="https://website-assets.studocu.com/img/apple/apple-touch-icon-120x120.png" /> | |
| <link rel="apple-touch-icon" sizes="152x152" | |
| href="https://website-assets.studocu.com/img/apple/apple-touch-icon-152x152.png" /> | |
| <link rel="apple-touch-icon" sizes="180x180" | |
| href="https://website-assets.studocu.com/img/apple/apple-touch-icon-180x180.png" /> | |
| <script | |
| data-react-universal-portal=""> | |
| window.__PAGE_PROVIDER_INITIAL_DATA__ = { | |
| 'numberOfPagesLoaded': 0, | |
| 'structure': [ | |
| STRUCTUREPLACEHOLDER | |
| '</div>' | |
| ], | |
| 'previewTextData': { 'isMarkdown': false } | |
| }; | |
| </script> | |
| <link rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/document-viewer-sass-9d962491935c0aca0cd037f196542372.css" | |
| data-react-universal-portal=""> | |
| <link rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/app-c4a7f2817ad58f71624b01ec0aad4c9d.css" | |
| data-react-universal-portal=""> | |
| <link data-chunk="DocumentViewerAppLean" rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/es7/16822-31d6cfe0d16ae931b73c.css"> | |
| <link data-chunk="DocumentViewerAppLean" rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/es7/11845-39b7b93d10909baca476.css"> | |
| <link data-chunk="DocumentViewerAppLean" rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/es7/18546-31d6cfe0d16ae931b73c.css"> | |
| <link data-chunk="DocumentViewerAppLean" rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/es7/DocumentViewerAppLean-d5ec966e3701404a0218.css"> | |
| <link data-chunk="partials-Details-ViewerDetailsApp" rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/es7/74288-de4cdbac8ffe67eda6ea37aac7a1a58d.css"> | |
| <link data-chunk="partials-DocumentPage-DocumentPage" rel="stylesheet" | |
| href="https://website-assets.studocu.com/build/webpack/web/es7/95441-ece9f2799b6839e7cd36e1943d670e5b.css"> | |
| <link rel="stylesheet" crossorigin="anonymous" type="text/css" | |
| href="https://doc-assets.studocu.com/ASSETIDREPLACEPOSITION/html/ASSETIDREPLACEPOSITION.cssSIGNEDQUERYPARAMS" | |
| data-react-universal-portal=""> | |
| </head> | |
| <body> | |
| <div id="redux-page-container"> | |
| <main id="main-wrapper" class="_05061e342776"> | |
| <div class="main-wrapper"> | |
| <div id="viewer-wrapper" class="_3368ac8a536b _ec038b23870a _67607ee5babf"> | |
| <article id="document-wrapper" class="_5616026bd798" tabindex="0"> | |
| <div></div> | |
| <div></div> | |
| </article> | |
| </div> | |
| </main> | |
| </div> | |
| <script> | |
| var classicApiSubdomain = "www"; | |
| var baseUrl = "https://www.studocu.com"; | |
| var currentUrl = "https://www.studocu.com/app/documents/84557664/lean?hideAppBanner=1"; | |
| var currentLocale = "en"; | |
| var environment = "production"; | |
| var userIsCrawler = false; | |
| </script> | |
| <div id="inject-scripts-container"></div> | |
| <script>window.__PAGE__ = "undefined"; | |
| window.__INITIAL_STATE__ = { | |
| 'document': { | |
| 'current': { | |
| 'title': 'Hausaufgabe 10.4', | |
| 'description': 'Hausaufgabe 10.4', | |
| 'pageTitle': 'Hausaufgabe 10.4 - Berechenbarkeit und Komplexität - Studocu', | |
| 'assets': { | |
| 'url': 'https://doc-assets.studocu.com/ASSETIDREPLACEPOSITION/html/', | |
| 'signedQueryParams': { 'global': 'SIGNEDQUERYPARAMS' }, | |
| 'validity': 86400 | |
| }, | |
| 'accessiblePages': [], | |
| 'pages': PAGECOUNT, | |
| 'source': 'Organic', | |
| 'userStudylistIds': [], | |
| 'active_file': { | |
| 'object_key': 'ASSETIDREPLACEPOSITION', | |
| 'extension': 'pdf', | |
| 'pages': PAGECOUNT, | |
| 'processed': true | |
| }, | |
| 'material_type': 1, | |
| 'ownDocument': false, | |
| 'hasBlurredImages': false, | |
| 'isFree': false | |
| } | |
| }, | |
| 'meta': { | |
| 'currentMaterial': 'Viewer', | |
| 'isApp': true, | |
| 'isAppLeanViewer': true, | |
| 'cdn': { | |
| 'cdn_enabled': true, | |
| 'aws_cloudfront_assets': 'https://website-assets.studocu.com', | |
| 'aws_cloudfront_document_assets': 'doc-assets.studocu.com' | |
| }, | |
| 'currentUrl': 'https://www.studocu.com/app/documents/84557664/lean', | |
| 'languages': { | |
| 'de': 'Deutsch', | |
| }, | |
| 'regions': [ | |
| { | |
| 'code': 'de', | |
| 'name': 'Germany', | |
| 'englishName': 'Germany', | |
| 'isDefault': false, | |
| 'landingPageUrl': 'https://www.studocu.com/de' | |
| } | |
| ] | |
| }, | |
| 'view': { | |
| 'showSaveButton': true, | |
| 'floatingElement': null, | |
| 'showShareModal': false, | |
| 'showSidebar': false, | |
| 'supportSelectedAction': 'none', | |
| 'showGroupMessages': false, | |
| 'showPremiumLabel': false, | |
| 'isSidebarCollapsed': null, | |
| 'hasTriggeredAIChatOutsideSidebar': false, | |
| 'showAIChat': false, | |
| 'showAIQuiz': false, | |
| 'isDocumentLongForAIQuiz': false, | |
| 'questionTokenLimit': 0 | |
| } | |
| }; | |
| </script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/13666-8e61ab44a06c19a0cc8b.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/15578-5b714a04900e758061dc.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/76429-687f1d01bdad92964dac.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/59242-792b8f71b5a1e9368b67.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/49685-4dfaa190734be18a1f04.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/95301-4e344138a1438139b225.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/62440-e5f60d631d71103cb069.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/75925-2c7a4061d921a64db0ec.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/58126-e3567defffbbcce7fb48.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/88618-009b13cf6dbca01f7ff8.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/51959-45e52083a0a10795da83.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/60962-bc2f9a533bbaf3522bba.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/61766-deb240f3c9c59eb3e8d2.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/11216-ff801c3c5fbcff3b3650.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/66265-0ea7f863d005b2905d1d.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/72341-38c49b2c3b52380a2368.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/66216-95588ad74cbe9171151e.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/18546-abc522603ad11fd917f3.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/44195-40257738871bb4fcc67d.js"></script> | |
| <script async data-chunk="DocumentViewerAppLean" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/16832-114e4ebe72ccb1a35b05.js"></script> | |
| <script async data-chunk="partials-Details-ViewerDetailsApp" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/74288-7f3457c781e0e206ff57.js"></script> | |
| <script async data-chunk="partials-DocumentPage-DocumentPage" | |
| src="https://website-assets.studocu.com/build/webpack/web/es7/95441-64992cd6769d91b8a459.js"></script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment