mirror of
https://gitlab.dit.htwk-leipzig.de/fsr-im/tools/flatscraper.git
synced 2026-01-16 12:42:25 +01:00
add initial scraping functionality and related utilities
This commit is contained in:
35
src/lwb/scrape_image.py
Normal file
35
src/lwb/scrape_image.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import requests
|
||||
|
||||
EASYSQUARE_HEADERS = {
|
||||
"DNT": "1",
|
||||
"Host": "portal1s.easysquare.com",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
"Cookie": "SAP_SESSIONID_PP0_581=zqFIhvNbEsOs_n3cgRTIO1V7ZaLQCxHvhYgKELG5Agg%3d; sap-usercontext=sap-language=D&sap-client=581; cookiesession1=678ADA67ADF0813997206FE9F4133118",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0",
|
||||
"Accept-Encoding": "gzip, deflate, br, zstd",
|
||||
"Accept-Language": "de,en-US;q=0.7,en;q=0.3",
|
||||
"Upgrade-Insecure-Requests": "1"
|
||||
}
|
||||
EASYSQUARE_PARAMS = {
|
||||
"application": "ESQ_IA_REOBJ",
|
||||
"sap-client": "581",
|
||||
"command": "action",
|
||||
"name": "boxlist",
|
||||
"api": "6.169",
|
||||
"head-oppc-version": "6.169.22",
|
||||
"_": "1736595414769"
|
||||
}
|
||||
|
||||
|
||||
def scrape_image(url):
|
||||
session = requests.Session()
|
||||
response = session.get(url, headers=EASYSQUARE_HEADERS, params=EASYSQUARE_PARAMS)
|
||||
|
||||
if response.status_code != 200:
|
||||
print(f"Fehler beim Abrufen von Easysquare: {response.status_code}")
|
||||
return []
|
||||
|
||||
# get image from response
|
||||
|
||||
return response.content
|
||||
|
||||
Reference in New Issue
Block a user