2
아래와 같이 스크립트를 실행하려고 할 때마다 다음 결과가 표시됩니다. 코드에 어떤 문제가 있습니까?URL을 인수로 전달
1. python test.py
는 사용을 인쇄하지 않습니다.
2. python test.py http://link.com/index.php?title=tesst&action=raw
인쇄 : "'action' is not recognized as an internal or external command, operable program or batch file."
내 스크립트를
# Version YYYYMMDD
version = "20121112"
# File type to be output to logs
# Should be changed to exe before building the exe.
fileType = "py"
# Import sys to read command line arguments
import sys, getopt
#import pdb
#pdb.set_trace()
import argparse
def update (url):
req = urllib2.Request(url=url)
try:
f = urllib2.urlopen(req)
txt = f.read()
f.close()
except urllib2.HTTPError, e:
txt = ''
print 'An error occured connecting to the wiki. No wiki page will be generated.'
return '<font color=\"red\">QWiki</font>'
# Find the start tag of the textarea with Regular Expressions
p = re.compile('<textarea[^>]*>')
m = p.search(txt)
(tagStart, tagEnd) = m.span()
# Find the end of the textarea
endTag = txt.index("</textarea>")
def main():
#For logging
print "test"
parser = argparse.ArgumentParser(description='This is the update.py script created by test')
parser.add_argument('-u','--ur',action='store',dest='url',default=None,help='<Required> url link',required=True)
results = parser.parse_args()# collect cmd line args
url = results.url
print url
update(url)
@blendar - 어떤 인수도 전달하지 않으면 사용법이 인쇄되지 않습니까? – user2125827
또한 "print url"로 URL을 인쇄하고 있습니다. 아무 것도 인쇄하지 않습니다. – user2125827