retrieving main paragraphs from python wikipedia page output
Date : March 29 2020, 07:55 AM
I wish this help you I leave my answer here because it is directly what the OP asked for. The proper way to do this is to use python-wikitools as suggested in the answer by @ChristophD below. import urllib2
import re, sys
from HTMLParser import HTMLParser
# EDIT 1: import the packag
from BeautifulSoup import BeautifulSoup
class MLStripper(HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, d):
self.fed.append(d)
def get_data(self):
return ''.join(self.fed)
def stripHTMLTags(html):
html = re.sub(r'<{1}br{1}>', '\n', html)
s = MLStripper()
s.feed(html)
text = s.get_data()
if "External links" in text:
text, sep, tail = text.partition('External links')
if "External Links" in text:
text, sep, tail = text.partition('External Links')
text = text = text.replace("See also","\n\n See Also - \n")
text = text.replace("*","- ")
text = text.replace(".", ". ")
text = text.replace(" "," ")
text = text.replace(""" /
/ ""","")
return text
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
infile = opener.open('http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes')
page = infile.read()
# EDIT 2: convert the page and extract text from the first <p> tag
soup = BeautifulSoup(page)
para = soup.findAll("p", limit=1)[0].text
print stripHTMLTags(para)
|
how to appear a window(div) on the site main page that site won't be clickable
Date : March 29 2020, 07:55 AM
This might help you I want to show a div with some buttons ,first time my site loads and I want that the site become not usable until that div closes with one of its buttons (like when you choose an image in image.google.com and after that you see the selected picture with the site it extracted from behind it but that site is a little dark and just like a photo of the site) <div id="overlay">
<div id="dialog">
Close me to see anything else
</div>
</div>
#overlay{
position:fixed;
z-index:9999;
top:0;
left:0;
width:100%;
height:100%;
background-color:rgba(0,0,0,.3);
}
#dialog{
width:200px;
height:100px;
margin-left:-100px;
margin-top:-50px;
left:50%;
top:50%;
position:absolute;
background-color:#ffffff;
border:1px solid #666;
padding:20px;
}
|
Create a new static page using blogdown with same hugo theme as main site
Date : March 29 2020, 07:55 AM
help you fix your problem I'm doing this for my classes. You can see the end result here, click on "teaching". You can see the source files in the GitHub repository. In particular look under the content/classes folder.
|
blogdown - how do I specify which page a post will appear on
Date : November 26 2020, 04:01 AM
This might help you In hugo, the layout of the website mirrors the layout of the files in the content directory. So, if you have a blog post in content/blog/my-cool-post.md, it will show up as https://example.com/blog/my-cool-post.html See hugo docs for a bit more.
|
Is there a way to change the width page of a html post in blogdown/hugo?
Tag : r , By : user105769
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , The width is determined by your theme. I only looked at an example site provided here but in this particular case, the element you need to deal with appears to be main-content-wrap. I came to this conclusion by right clicking on my browser and picking "Inspect Element" (firefox) or "Inspect" (chrome) which gives you information about which elements are present and how are they effected by existing CSS. From here you can see that it has a default max-width of 750px. You need to create a CSS file to overwrite this property. The file only has to contain .main-content-wrap{
max-width: [insertYourDesiredWidthHere]px
}
[[params.customCSS]]
href = "pathToFileUnderStatic"
|