Browse Source

fetching mediawikipage content

master
jules 4 years ago
parent
commit
c9342c56d3
  1. 32
      daapinterface.py
  2. 6
      templates/about-wiki.html
  3. 78
      templates/layout-later.html

32
daapinterface.py

@ -8,6 +8,11 @@ import requests
from SPARQLWrapper import SPARQLWrapper, JSON
import json
# import pandas as pd
# ##### IMPORTS FOR TEST WIKIPAGE
from lxml import html
from bs4 import BeautifulSoup
# # # # # # # # # # # # # # # # # # # # # # # #
# GETTING STARTED
@ -350,7 +355,16 @@ def searchtools():
######################### ABOUT
@app.route("/about")
def about():
return render_template('about.html')
url="https://daap.bannerrepeater.org/w/index.php?title=Project:About&action=render"
# Make a GET request to fetch the raw HTML content
html_content = requests.get(url).text
# Parse the html content
soup = BeautifulSoup(html_content, "lxml")
print(soup.prettify()) # print the parsed data of html
text=soup.find("p")
return render_template('about-wiki.html', text=text)
######################### TUTORIAL
@app.route("/tutorials")
@ -367,7 +381,21 @@ def upload():
######################### LOGIN
#Goes to wikibase page
# ###################
# TEST
response = requests.get(
'https://daap.bannerrepeater.org/w/api.php',
params={
'action': 'parse',
'page': 'Test',
'format': 'json',
}).json()
raw_html = response['parse']['text']['*']
document = html.document_fromstring(raw_html)
first_p = document.xpath('//p')[0]
intro_text = first_p.text_content()
print(intro_text)
# ALL NAME

6
templates/about-wiki.html

@ -0,0 +1,6 @@
{% extends "layout.html" %}
{% block content %}
{{ text }}
{% endblock content %}

78
templates/layout-later.html

@ -1,78 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>D.A.A.P</title>
<link rel="stylesheet" href="{{ url_for('static', filename='/css/style.css') }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
</head>
<body>
<div id="header">
<div id="header-top">
<div id="animatedlogo">
<img src="{{ url_for('static', filename='/imgs/Logos/DAAP BR square logo -Animated Image (Small).gif') }}">
</div>
<div id="header-title">
<a href="{{ url_for('home') }}">DIGITAL ARCHIVE OF ARTISTS' PUBLISHING</a>
</div>
<div id="header-keyword-search">
<input type="text" id="fname" name="fname" value="Keyword search">
</div>
</div>
<div id="navigation">
<div id="nav-about"><a href="{{ url_for('about') }}">About</a></div>
<div id="nav-browse-archive"><a href="{{ url_for('browsethearchive') }}">Browse the archive</a></div>
<div id="nav-browse-category"><a href="{{ url_for('browsebycategory') }}">Browse by category</a></div>
<div id="nav-search"><a href="{{ url_for('searchtools') }}">Search tools</a></div>
<div id="nav-tutorials"><a href="{{ url_for('tutorials') }}">Tutorials</a></div>
<div id="nav-upload"><a href="{{ url_for('upload') }}">Upload</a></div>
<div id="nav-login"><a href="https://daap.bannerrepeater.org/w/index.php?title=Special:UserLogin&returnto=Main+Page">Log in</a></div>
</div>
</div>
{% block content %}
{% endblock content %}
<div id="footer">
<!-- <div id="footer-br"> -->
<div id="footer-title-br"><p>A project by:</p></div>
<div id="footer-img-br"><img src="{{ url_for('static', filename='/imgs/Logos/Banner-Repeater-logo.png') }}"></div>
<!-- </div> -->
<!-- <div id="footer-others"> -->
<div id="footer-title-others"><p>With support from:</p></div>
<div id="footer-img-others">
<div id="footer-img-wiki"><img src="{{ url_for('static', filename='/imgs/Logos/wikimedia_logo.png') }}"></div>
<div id="footer-img-lottery"><img src="{{ url_for('static', filename='/imgs/Logos/Lottery-white on black.png') }}"></div>
</div>
<div id="footer-title-socials"><p>SOCIAL</p></div>
<div id="footer-socials-links">
<p><a target="_blank" href="https://www.facebook.com/BannerRepeater">Facebook</a></p>
<p><a target="_blank" href="https://twitter.com/BANNERREPEATER">Twitter</a></p>
<p><a target="_blank" href="https://www.instagram.com/bannerrepeater/">Instagram</a></p>
<p><a target="_blank" href="mailto:daap.community@disroot.org">Email address</a></p>
</div>
<div id="footer-title-contact"><p>EXPRESSION OF INTEREST</p></div>
<div id="footer-contact"><a href=""><div class="bluebutton" id="contactform">FILL UP CONTACT FORM<span></span></div></a></div>
</div>
</body>
</html>
Loading…
Cancel
Save