Created
July 23, 2010 09:56
-
-
Save saga/487232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp.util import run_wsgi_app | |
import logging | |
from google.appengine.api import urlfetch | |
from BeautifulSoup import * | |
class SoapLinks(webapp.RequestHandler): | |
def get(self, url): | |
url = url.replace('%3A', ':', 1) | |
params = url.split('/') | |
del params[-1] | |
baseUrl = "/".join(params) | |
baseUrl = baseUrl + "/" | |
resultStr = "" | |
response = urlfetch.fetch(url, method=urlfetch.GET) | |
if response.status_code == 200: | |
content = response.content | |
resultList = list() | |
#logging.debug(r"SoapLinks get %s" % content) | |
self.response.headers['Content-Type'] = 'text/html;charset=utf-8' | |
soaplinkstmp = BeautifulSoup(content, parseOnlyThese=SoupStrainer('dd')) | |
for dda in soaplinkstmp: | |
if dda.contents[0].find("_img") >= 0: | |
self.response.out.write("<a href='%s'>%s</a>" % (dda.contents[0], dda.contents[0])) | |
self.response.out.write("<br />") | |
logging.debug(r"SoapLinks Tmp get %s", dda.contents[0]) | |
def main(): | |
application = webapp.WSGIApplication( | |
[ | |
(r'/soaplinks/(.*)', SoapLinks)], | |
debug=True) | |
run_wsgi_app(application) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment