<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=User%3AAlterego%2Fsignpost.py</id>
	<title>User:Alterego/signpost.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=User%3AAlterego%2Fsignpost.py"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=User:Alterego/signpost.py&amp;action=history"/>
	<updated>2026-05-07T15:42:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=User:Alterego/signpost.py&amp;diff=2018354&amp;oldid=prev</id>
		<title>imported&gt;Qwerfjkl (bot): /* Required Modules */Replaced deprecated &lt;source&gt; tags with &lt;syntaxhighlight&gt;</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=User:Alterego/signpost.py&amp;diff=2018354&amp;oldid=prev"/>
		<updated>2022-05-08T14:37:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Required Modules: &lt;/span&gt;Replaced deprecated &amp;lt;source&amp;gt; tags with &amp;lt;syntaxhighlight&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is the python script I wrote for creating an RSS feed of the [[Wikipedia:Wikipedia_Signpost|Wikipedia Signpost]]. &lt;br /&gt;
Note: This is an out of date version that I salvaged. It has some debugging stuff in it. I&amp;#039;m still trying to do data rescue on my crashed server (just don&amp;#039;t have much time)&lt;br /&gt;
&lt;br /&gt;
==== Required Modules ====&lt;br /&gt;
It requires the following modules:&lt;br /&gt;
*Scrape &amp;#039;N&amp;#039; Feed: [http://www.crummy.com/software/ScrapeNFeed/ http://www.crummy.com/software/ScrapeNFeed/]&lt;br /&gt;
*BeautifulSoup: [http://www.crummy.com/software/BeautifulSoup/ http://www.crummy.com/software/BeautifulSoup/]&lt;br /&gt;
*PyRSS2Gen: [http://www.dalkescientific.com/Python/PyRSS2Gen.html http://www.dalkescientific.com/Python/PyRSS2Gen.html]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#    Copyright (c) 2005, Brian Mingus&lt;br /&gt;
#    This program is free software; you can redistribute it and/or modify&lt;br /&gt;
#    it under the terms of the GNU General Public License as published by&lt;br /&gt;
#    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
#    (at your option) any later version.&lt;br /&gt;
&lt;br /&gt;
#    This program is distributed in the hope that it will be useful,&lt;br /&gt;
#    but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
#    GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
#    You should have received a copy of the GNU General Public License&lt;br /&gt;
#    along with this program; if not, write to the Free Software&lt;br /&gt;
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA&lt;br /&gt;
&lt;br /&gt;
import cgi&lt;br /&gt;
import urllib&lt;br /&gt;
import re&lt;br /&gt;
import time&lt;br /&gt;
import ScrapeNFeed&lt;br /&gt;
from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup&lt;br /&gt;
from PyRSS2Gen import RSSItem, Guid&lt;br /&gt;
from ftplib import FTP&lt;br /&gt;
&lt;br /&gt;
# Change user agent to something not banned&lt;br /&gt;
class AppURLopener(urllib.FancyURLopener):&lt;br /&gt;
   def __init__(self, *args):&lt;br /&gt;
                      # Replace this with what you want to use&lt;br /&gt;
      self.version = &amp;quot;User:Alterego for Wikipedia Signpost RSS feed&amp;quot;&lt;br /&gt;
      apply(urllib.FancyURLopener.__init__, (self,) + args)&lt;br /&gt;
&lt;br /&gt;
urllib._urlopener = AppURLopener()&lt;br /&gt;
&lt;br /&gt;
# Download the signpost and parse the xml structure with BeautifulStoneSoup&lt;br /&gt;
# Note that this is from Special:Export&lt;br /&gt;
url = &amp;#039;http://en.wikipedia.org/wiki/Special:Export/Wikipedia:Wikipedia_Signpost&amp;#039;&lt;br /&gt;
wikitext = urllib.urlopen(url)&lt;br /&gt;
signpost = BeautifulStoneSoup(wikitext)&lt;br /&gt;
&lt;br /&gt;
# Find all the links to articles&lt;br /&gt;
# Regexp: four char digit, dash, two char digit, dash, two char digit, any chars a until a pipe&lt;br /&gt;
signpost = re.findall(r&amp;quot;\d{4}\-\d{2}\-\d{2}/[^\|]+&amp;quot;,  signpost.text.string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class signpostFeed(ScrapeNFeed.ScrapedFeed):&lt;br /&gt;
&lt;br /&gt;
      def HTML2RSS(self, headers, body):&lt;br /&gt;
&lt;br /&gt;
        soup = BeautifulSoup(body)&lt;br /&gt;
        &lt;br /&gt;
        # Gather the html body of the story.        &lt;br /&gt;
        start = soup.h2.findNext(&amp;#039;p&amp;#039;)&lt;br /&gt;
        end = soup.h2.findNext(&amp;#039;div&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
        while start != end:&lt;br /&gt;
          &lt;br /&gt;
          if start != None:&lt;br /&gt;
            &lt;br /&gt;
            # If it hasn&amp;#039;t already been added to body&lt;br /&gt;
            if str(start) in textWeWant:&lt;br /&gt;
              &lt;br /&gt;
              textWeWant += str(start)&lt;br /&gt;
              &lt;br /&gt;
          # Move to next element&lt;br /&gt;
          start = start.next&lt;br /&gt;
        &lt;br /&gt;
        # Let BeautifulSoup make the code pretty&lt;br /&gt;
        textWeWant = BeautifulSoup(textWeWant).prettify()&lt;br /&gt;
        &lt;br /&gt;
        # And convert all relative links to absolute&lt;br /&gt;
        textWeWant.replace(&amp;#039;&amp;quot;/wiki/&amp;#039;,&amp;#039;&amp;quot;http://en.wikipedia.org/wiki/&amp;#039;)&lt;br /&gt;
        &lt;br /&gt;
        # And escape all html entities so they render in RSS&lt;br /&gt;
        # Note that for html display, I use Magpie, which&lt;br /&gt;
        # will unescape all these later&lt;br /&gt;
        # Note that non-intelligent rss readers won&amp;#039;t render the html&lt;br /&gt;
        # but Bloglines does and that&amp;#039;s what I use&lt;br /&gt;
        textWeWant = cgi.escape(textWeWant)&lt;br /&gt;
        print textWeWant&lt;br /&gt;
&lt;br /&gt;
        items = []&lt;br /&gt;
        #if not self.hasSeen(textWeWant):&lt;br /&gt;
        items.append(RSSItem(title=soup.h2.string,&lt;br /&gt;
                             description = textWeWant,&lt;br /&gt;
                             link = self.url))&lt;br /&gt;
        self.addRSSItems(items)&lt;br /&gt;
&lt;br /&gt;
for i in range(len(signpost)):&lt;br /&gt;
  print &amp;#039;i is :&amp;#039;&lt;br /&gt;
  print i&lt;br /&gt;
  print &amp;#039;signpost is :&amp;#039;&lt;br /&gt;
  print signpost[i]&lt;br /&gt;
  signpostFeed.load(&amp;quot;Wikipedia Signpost&amp;quot;,&lt;br /&gt;
                    &amp;#039;http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_Signpost/&amp;#039; + signpost[i].replace(&amp;#039; &amp;#039;,&amp;#039;_&amp;#039;),&lt;br /&gt;
                    &amp;#039;The Wikipedia Signpost is a community-written and community-edited \&lt;br /&gt;
                     newspaper, covering events and stories related to the English Wikipedia.&amp;#039;,&lt;br /&gt;
                    &amp;#039;F:\\signpost.rss&amp;#039;,&lt;br /&gt;
                    &amp;#039;F:\\signpost.pickle&amp;#039;)&lt;br /&gt;
  &lt;br /&gt;
# FTP server information for uploading the feed&lt;br /&gt;
&lt;br /&gt;
ftp = FTP(&amp;#039;&amp;#039;,&amp;#039;&amp;#039;,&amp;#039;&amp;#039;)&lt;br /&gt;
ftp.set_debuglevel(2)&lt;br /&gt;
ftp.storlines(&amp;#039;STOR&amp;#039;,&amp;#039;f:\signpost.rss&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Qwerfjkl (bot)</name></author>
	</entry>
</feed>