That's not arabic ^
That's not arabic ^
My entry:
Code:#!/usr/bin/env python import urllib import re t = re.compile('<title>(.*)</title>') url = raw_input('What page do you wish to copy?\n') index = urllib.urlopen(str(url)).read() title = t.search(index).group(1) f = open(str(title), 'w') f.write(index) f.close() print 'Saved as %s .xhtml' % (title)
Not really,Hindi if I am not mistaken.I know arabic so I would have known..
http://en.wikipedia.org/wiki/Hindi
ur right thanks
ok a few questions
- 1. can you explain the render thing better...i don't get that but i found a good example on the web that taught me how to do this challenge but has poor documentation and mentions something about renders in the comments
- 2. is it just me or are the forum tags the same has html/xhtml tags but with [] brackets instead of <> ones
This is more or less true but HTML has a lot more tags than BBC (forum) code has.2. is it just me or are the forum tags the same has html/xhtml tags but with [] brackets instead of <> ones
always wanted to do this in perl,
here's mine:
Code:## Ubuntu Challenge #4, written by Badperson 8/14/08 ## this script will default to look for http://laroza.freehostia.com/home/index.php, ## but will accept an arugument for a url use LWP::Simple; use strict; use warnings; my $url; if (@ARGV == 1 ){ $url = $ARGV[0]; } else { $url = "http://laroza.freehostia.com/home/index.php"; } my $content = get($url) or die "can't read $url $!\n"; open(OUT, ">index.xhtml"); print OUT '<!-- Ubuntu Challenge #4, written by Badperson 8/14/08 -->'; print OUT '<!-- searching for url: $url -->'; print $content; print OUT $content; print "\n\nScript done. \n";
also does the program have to load it or just save it to a xhtml file
OK, I thought this was the perfect opportunity to practice the PyQt that I was learning, so I created both a CLI version and a GUI version, for the GUI version you need to have Qt4 and PyQt4 both installed.
The CLI version:
The GUI Version:PHP Code:
import urllib2
class WebsiteCopier(object):
def SaveWebsite(self):
try:
websiteChoice = raw_input("What website would you like to copy?: ")
website = urllib2.urlopen(str(websiteChoice)).read()
fileTitle = website.split("<title>")[1].split("</title>")[0] + ".xhtml"
websiteFile = open(fileTitle, "w")
websiteFile.writelines(website)
print "Successfully completed copying website to " + fileTitle + "!"
except:
print "Error in downloading or writing website to file."
finally:
websiteFile.close()
if __name__ == "__main__":
WebsiteCopier = WebsiteCopier()
WebsiteCopier.SaveWebsite()
Suggesstions, etc... are welcomedPHP Code:
import sys
import urllib2
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class WebsiteForm(QDialog):
def __init__(self, parent=None):
super(WebsiteForm,self).__init__(parent)
self.WebsiteLine = QLineEdit("Type a website URL here.")
self.WebsiteLine.selectAll()
self.browser = QTextBrowser()
grid = QGridLayout()
grid.addWidget(self.WebsiteLine, 0, 0)
grid.addWidget(self.browser, 1, 0)
self.setLayout(grid)
self.setWindowTitle("Website Copier")
self.connect(self.WebsiteLine, SIGNAL("returnPressed()"), self.updateUi)
def updateUi(self):
try:
text = self.WebsiteLine.text()
website = urllib2.urlopen(str(text)).read()
fileTitle = website.split("<title>")[1].split("</title>")[0] + ".xhtml"
websiteFile = open(fileTitle, "w")
websiteFile.writelines(website)
self.browser.append("<b>Successfully finished saving website to %s!</b>" % fileTitle)
except:
self.browser.append("<font color=red>%s is an invalid website URL!</font>" % text)
finally:
websiteFile.close()
app = QApplication(sys.argv)
form = WebsiteForm()
form.show()
app.exec_()
Cheers
Last edited by OutOfReach; August 14th, 2008 at 09:49 PM.
Blog | I'm available for programming contributions. C & Python.
Intel Core i7 920 | EVGA x58 SLI | NVidia GeForce 8600 GT | WD 500GB HDD | Corsair XMS3 3GB | Ubuntu 9.04
Bookmarks