✨ signatures is now scraped!
Co-authored-by: haraldnilsen <harald_998@hotmail.com> Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
0da7504104
commit
7247576022
1 changed files with 16 additions and 1 deletions
17
main.py
17
main.py
|
@ -48,10 +48,25 @@ def fetch_all_info(url):
|
||||||
# Extracting the question and answer
|
# Extracting the question and answer
|
||||||
sporsmal = html.css_first('div.article-text').text()
|
sporsmal = html.css_first('div.article-text').text()
|
||||||
|
|
||||||
|
# Check if the element exists before accessing its text
|
||||||
|
signatur_div = html.css_first('div.signatur')
|
||||||
|
signatur = ""
|
||||||
|
if signatur_div:
|
||||||
|
signaturTxt = signatur_div.text()
|
||||||
|
# Remove "Med vennlig hilsen" or "Vennlig hilsen"
|
||||||
|
signaturTxt = signaturTxt.replace("Med vennlig hilsen", "").replace("Vennlig hilsen", "").strip()
|
||||||
|
# Check if the text is empty after removal
|
||||||
|
if signaturTxt:
|
||||||
|
signatur = signaturTxt
|
||||||
|
else:
|
||||||
|
signatur = "Null signatur"
|
||||||
|
else:
|
||||||
|
signatur = "Null signatur"
|
||||||
|
|
||||||
# Create array of results
|
# Create array of results
|
||||||
#result = [sporsmal, svar, signatur]
|
#result = [sporsmal, svar, signatur]
|
||||||
|
|
||||||
return sporsmal
|
return signatur
|
||||||
|
|
||||||
studenterspor_url = "https://www.studenterspor.no/ajax_handler.php"
|
studenterspor_url = "https://www.studenterspor.no/ajax_handler.php"
|
||||||
urls = fetch_question_url(studenterspor_url)
|
urls = fetch_question_url(studenterspor_url)
|
||||||
|
|
Reference in a new issue